diff --git a/devshell.nix b/devshell.nix deleted file mode 100644 index 77393a6..0000000 --- a/devshell.nix +++ /dev/null @@ -1,20 +0,0 @@ -{inputs, ...}: { - imports = [inputs.agenix-rekey.flakeModule]; - - perSystem = { - system, - pkgs, - ... - }: { - devShells.default = pkgs.mkShell { - inherit system; - - packages = [ - pkgs.nix - pkgs.nixos-rebuild - pkgs.nixos-rebuild - pkgs.nh - ]; - }; - }; -} diff --git a/flake.lock b/flake.lock index 1c23f17..8076884 100644 --- a/flake.lock +++ b/flake.lock @@ -34,11 +34,11 @@ "treefmt-nix": "treefmt-nix" }, "locked": { - "lastModified": 1738758381, - "narHash": "sha256-cNEfY2a6amDIMHNcgiBDqwUHg+vA2C9evIeLHb+AVDI=", + "lastModified": 1739816852, + "narHash": "sha256-QG8aA6hWsi6pqaidaz5a5SL+dM1mT9LMWMrmc1hrOrU=", "owner": "oddlama", "repo": "agenix-rekey", - "rev": "2df379f6fec3ecc4190e1778b29a3eceef86d546", + "rev": "5f56d711ffe2aca62cfeeada9ec56692a13b9061", "type": "github" }, "original": { @@ -96,11 +96,11 @@ ] }, "locked": { - "lastModified": 1739380580, - "narHash": "sha256-wGtGEfdooudj74wn59Vu5Z2DLsrX9cxdGTFc9sJrP9M=", + "lastModified": 1740081950, + "narHash": "sha256-h6RFLln99Br7o0TmtKE+vd6F2PQiGBIrRobf4Ld2wRA=", "owner": "aylur", "repo": "astal", - "rev": "956b74fd9ff8c607b6683b404860c4e6b30ffe2b", + "rev": "3620d51bc6c23ada1bd4b7c9cf1c458c138e68df", "type": "github" }, "original": { @@ -120,11 +120,11 @@ "stable": "stable" }, "locked": { - "lastModified": 1734897875, - "narHash": "sha256-LLpiqfOGBippRax9F33kSJ/Imt8gJXb6o0JwSBiNHCk=", + "lastModified": 1739900653, + "narHash": "sha256-hPSLvw6AZQYrZyGI6Uq4XgST7benF/0zcCpugn/P0yM=", "owner": "zhaofengli", "repo": "colmena", - "rev": "a6b51f5feae9bfb145daa37fd0220595acb7871e", + "rev": "2370d4336eda2a9ef29fce10fa7076ae011983ab", "type": "github" }, "original": { @@ -183,11 +183,11 @@ ] }, "locked": { - "lastModified": 1739529569, - "narHash": "sha256-sQzLVCRPfAV/TJXru/jhCyecMXinG/sW8KLoYg0nOpk=", + "lastModified": 1739841949, + "narHash": "sha256-lSOXdgW/1zi/SSu7xp71v+55D5Egz8ACv0STkj7fhbs=", "owner": "nix-community", "repo": "disko", - "rev": "e51159153b5fbe5c41caab41a7212df93c42d34b", + "rev": "15dbf8cebd8e2655a883b74547108e089f051bf0", "type": "github" }, "original": { @@ -389,11 +389,11 @@ ] }, "locked": { - "lastModified": 1739570999, - "narHash": "sha256-eCc0/Q4bPpe4/AS+uzIrHLJcR6BxPQ69q2kD0/Qe6rU=", + "lastModified": 1739757849, + "narHash": "sha256-Gs076ot1YuAAsYVcyidLKUMIc4ooOaRGO0PqTY7sBzA=", "owner": "nix-community", "repo": "home-manager", - "rev": "254d47082e23dbf72fdeca1da6fe1da420f478d8", + "rev": "9d3d080aec2a35e05a15cedd281c2384767c2cfe", "type": "github" }, "original": { @@ -431,11 +431,11 @@ ] }, "locked": { - "lastModified": 1739676768, - "narHash": "sha256-U1HQ7nzhJyVVXUgjU028UCkbLQLEIkg42+G7iIiBmlU=", + "lastModified": 1740281615, + "narHash": "sha256-dZWcbAQ1sF8oVv+zjSKkPVY0ebwENQEkz5vc6muXbKY=", "owner": "nix-community", "repo": "nix-index-database", - "rev": "ae15068e79e22b76c344f0d7f8aed1bb1c5b0b63", + "rev": "465792533d03e6bb9dc849d58ab9d5e31fac9023", "type": "github" }, "original": { @@ -451,11 +451,11 @@ "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1739670916, - "narHash": "sha256-Tdzu06QlI8DsYdXNe96c9eu0clj9Wkd1cKo6em/0xPU=", + "lastModified": 1740275623, + "narHash": "sha256-LQ9hq3hKwWqm+dzBhgsIkr2KO6Bb0aU+yO/TtI7hXXo=", "owner": "nix-community", "repo": "nix-vscode-extensions", - "rev": "370af219cf4ad7660e3ad4577849fb0478edb33c", + "rev": "35ff5dce04469e7b4e56a9d997e5201bfce52ae3", "type": "github" }, "original": { @@ -533,11 +533,11 @@ }, "nixpkgs-unstable": { "locked": { - "lastModified": 1739446958, - "narHash": "sha256-+/bYK3DbPxMIvSL4zArkMX0LQvS7rzBKXnDXLfKyRVc=", + "lastModified": 1740126099, + "narHash": "sha256-ozoOtE2hGsqh4XkTJFsrTkNxkRgShxpQxDynaPZUGxk=", "owner": "nixos", "repo": "nixpkgs", - "rev": "2ff53fe64443980e139eaa286017f53f88336dd0", + "rev": "32fb99ba93fea2798be0e997ea331dd78167f814", "type": "github" }, "original": { @@ -549,11 +549,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1739357830, - "narHash": "sha256-9xim3nJJUFbVbJCz48UP4fGRStVW5nv4VdbimbKxJ3I=", + "lastModified": 1740162160, + "narHash": "sha256-SSYxFhqCOb3aiPb6MmN68yEzBIltfom8IgRz7phHscM=", "owner": "nixos", "repo": "nixpkgs", - "rev": "0ff09db9d034a04acd4e8908820ba0b410d7a33a", + "rev": "11415c7ae8539d6292f2928317ee7a8410b28bb9", "type": "github" }, "original": { @@ -565,11 +565,11 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1739482815, - "narHash": "sha256-/5Lwtmp/8j+ro32gXzitucSdyjJ6QehfJCL58WNA7N0=", + "lastModified": 1735554305, + "narHash": "sha256-zExSA1i/b+1NMRhGGLtNfFGXgLtgo+dcuzHzaWA6w3Q=", "owner": "nixos", "repo": "nixpkgs", - "rev": "ba0939c506a03c60a765cd7f7c43794816540eec", + "rev": "0e82ab234249d8eee3e8c91437802b32c74bb3fd", "type": "github" }, "original": { @@ -588,11 +588,11 @@ "treefmt-nix": "treefmt-nix_2" }, "locked": { - "lastModified": 1739903703, - "narHash": "sha256-w2tTcjx39lJoPDaFbIxi+INIjAKE0jbIx9TNjj9ghmg=", + "lastModified": 1740340210, + "narHash": "sha256-4ChQlobPMj36419ftR8Ijp1SOIQOkE46zrIbX8krqso=", "owner": "nix-community", "repo": "NUR", - "rev": "2215ad5c4347f522523715e809f5f2022509f504", + "rev": "54f385108fd1275597cd840ed6c6e3eb9d4ad302", "type": "github" }, "original": { @@ -753,11 +753,11 @@ "nixpkgs": "nixpkgs_3" }, "locked": { - "lastModified": 1738953846, - "narHash": "sha256-yrK3Hjcr8F7qS/j2F+r7C7o010eVWWlm4T1PrbKBOxQ=", + "lastModified": 1739829690, + "narHash": "sha256-mL1szCeIsjh6Khn3nH2cYtwO5YXG6gBiTw1A30iGeDU=", "owner": "numtide", "repo": "treefmt-nix", - "rev": "4f09b473c936d41582dd744e19f34ec27592c5fd", + "rev": "3d0579f5cc93436052d94b73925b48973a104204", "type": "github" }, "original": { @@ -774,11 +774,11 @@ "systems": "systems_3" }, "locked": { - "lastModified": 1739196332, - "narHash": "sha256-THwDbGY325LdIQQiBq1xE/LDgPCOtmaowh4LfzkIuu8=", + "lastModified": 1740299512, + "narHash": "sha256-l6WxKXm2kS3T1kDQC3gcq9AG8ALHr4b53ruWB2YKzMk=", "owner": "abenz1267", "repo": "walker", - "rev": "a3c1cb1ff5a83c0b8d94933b75702d550f2cc8a3", + "rev": "c0078bff61bd9945fb62b88ce705c6f363a7635e", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 90d74b0..a4fcfbb 100644 --- a/flake.nix +++ b/flake.nix @@ -68,7 +68,6 @@ flake-parts.lib.mkFlake {inherit inputs;} { imports = [ inputs.agenix-rekey.flakeModule - ./devshell.nix ./vm.nix ./formatter.nix ./hosts diff --git a/justfile b/justfile index 066bf92..f02094a 100644 --- a/justfile +++ b/justfile @@ -47,13 +47,22 @@ vm-destroy: virsh pool-destroy nixos virsh pool-undefine nixos +[doc("Build a flake output")] +build target='': + @{{ nixcmd }} run nixpkgs#nix-output-monitor -- build {{ justfile_directory() }}#{{ target }} + +[doc('Build a nixos configuration')] +[group('deploy')] +build-system hostname: + @just build nixosConfigurations."{{ hostname }}".config.system.build.toplevel + [doc('Wrapper for nixos-facter')] [group('deploy')] -factor hostname target='': +factor hostname=`hostname -s` target='': #!/usr/bin/env -S bash -e target="{{ target }}" if [ -z "$target" ]; then - {{ nixcmd }} run nixpkgs#nixos-facter -- -o hosts/{{ hostname }}/facter.json + sudo {{ nixcmd }} run nixpkgs#nixos-facter -- -o hosts/{{ hostname }}/facter.json else {{ nixcmd }} run github:nix-community/nixos-anywhere -- \ --flake .#{{ hostname }} \ @@ -64,11 +73,11 @@ factor hostname target='': [doc('Wrapper for nixos-rebuild switch')] [group("deploy")] -switch hostname target='': +switch hostname=`hostname -s` target='': (build-system hostname) #!/usr/bin/env -S bash -e target="{{ target }}" if [ -z "$target" ]; then - {{ nixcmd }} run nixpkgs#nixos-rebuild -- switch --flake .#{{ hostname }} + sudo {{ nixcmd }} run nixpkgs#nixos-rebuild -- switch --fast --flake .#{{ hostname }} else {{ nixcmd }} run nixpkgs#nixos-rebuild -- switch \ --flake .#{{ hostname }} \ @@ -78,7 +87,7 @@ switch hostname target='': [doc('Use nixos-anywhere to deploy to a remote host')] [group('deploy')] -deploy-remote hostname target: +deploy-remote hostname target: (build-system hostname) #!/usr/bin/env -S bash -e git add . @@ -103,7 +112,7 @@ deploy-remote hostname target: [doc('A wrapper disko-install')] [group('deploy')] -disko-install hostname disk="/dev/sda": +disko-install hostname disk: (build-system hostname) sudo {{ nixcmd }} run 'github:nix-community/disko/latest#disko-install' -- --flake .#{{ hostname }} --disk main {{ disk }} [doc('Build an install ISO for a host')] @@ -163,3 +172,22 @@ new-host hostname username: ]; }; EOF + +[doc("Update flake.lock")] +update: + {{ nixcmd }} flake update + +[doc("Run nix-tree")] +[group("tools")] +tree *ARGS=("--derivation .#nixosConfigurations." + shell("hostname -s") + ".config.system.build.toplevel"): + {{ nixcmd }} run github:utdemir/nix-tree -- {{ ARGS }} + +[doc("Run nix-diff between current system")] +[group("tools")] +diff: build + {{ nixcmd }} run nixpkgs#nvd -- diff /run/current-system {{ justfile_directory() }}/result + +[doc("Run nurl")] +[group("tools")] +nurl *ARGS="--help": + {{ nixcmd }} run nixpkgs#nurl -- {{ ARGS }} diff --git a/modules/base/gc.nix b/modules/base/gc.nix new file mode 100644 index 0000000..eb7ee2f --- /dev/null +++ b/modules/base/gc.nix @@ -0,0 +1,11 @@ +_: { + boot.loader.systemd-boot.configurationLimit = 10; + + nix.gc = { + automatic = true; + dates = "weekly"; + options = "--delete-older-than 1w"; + }; + + nix.settings.auto-optimise-store = true; +} diff --git a/modules/required.nix b/modules/required.nix index d0ddfa1..72220a3 100644 --- a/modules/required.nix +++ b/modules/required.nix @@ -9,6 +9,7 @@ ./base/time.nix ./base/ssh.nix ./base/default-apps.nix + ./base/gc.nix ./dev/just.nix ./hardware/usb.nix ./hardware/yubikey.nix diff --git a/modules/shell/core.nix b/modules/shell/core.nix index caf6e6d..4c94f39 100644 --- a/modules/shell/core.nix +++ b/modules/shell/core.nix @@ -38,9 +38,6 @@ unzip gzip xz - - # Nix - nurl ]; }; } diff --git a/result b/result index 7862996..00053e1 120000 --- a/result +++ b/result @@ -1 +1 @@ -/nix/store/nc1f93w32gkn9i69vhfi88fp53q29ib7-nixos-24.11.20250212.0ff09db-x86_64-linux.iso \ No newline at end of file +/nix/store/pbkcpq4n56acyyrbxlqgcsh7gng6ksb4-nixos-system-desktop-24.11.20250221.11415c7 \ No newline at end of file