diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..82e0cdf0 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/result \ No newline at end of file diff --git a/devbox/configuration.nix b/devbox/configuration.nix index 72268fc8..95fa33a4 100644 --- a/devbox/configuration.nix +++ b/devbox/configuration.nix @@ -16,9 +16,6 @@ # Temporary due to spice-autorandr nixpkgs.config.allowUnsupportedSystem = true; - # Faster ISO creation - isoImage.squashfsCompression = "gzip -Xcompression-level 1"; - environment.variables = { TERMINAL = "terminator"; }; diff --git a/flake.lock b/flake.lock index b17c429c..9198d819 100644 --- a/flake.lock +++ b/flake.lock @@ -98,6 +98,42 @@ "type": "github" } }, + "nixlib": { + "locked": { + "lastModified": 1719708727, + "narHash": "sha256-XFNKtyirrGNdehpg7lMNm1skEcBApjqGhaHc/OI95HY=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "1bba8a624b3b9d4f68db94fb63aaeb46039ce9e6", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "nixos-generators": { + "inputs": { + "nixlib": "nixlib", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1720859326, + "narHash": "sha256-i8BiZj5faQS6gsupE0S9xtiyZmWinGpVLwxXWV342aQ=", + "owner": "nix-community", + "repo": "nixos-generators", + "rev": "076ea5b672bb1ea535ee84cfdabd0c2f0b7f20c7", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixos-generators", + "type": "github" + } + }, "nixos-hardware": { "locked": { "lastModified": 1721331912, @@ -151,6 +187,7 @@ "home-manager": "home-manager", "microvm": "microvm", "nix-darwin": "nix-darwin", + "nixos-generators": "nixos-generators", "nixos-hardware": "nixos-hardware", "nixpkgs": "nixpkgs", "sops-nix": "sops-nix" diff --git a/flake.nix b/flake.nix index 30ad738e..39ec13dc 100644 --- a/flake.nix +++ b/flake.nix @@ -15,6 +15,10 @@ url = "github:LnL7/nix-darwin"; inputs.nixpkgs.follows = "nixpkgs"; }; + nixos-generators = { + url = "github:nix-community/nixos-generators"; + inputs.nixpkgs.follows = "nixpkgs"; + }; nixos-hardware.url = "github:NixOS/nixos-hardware"; nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; sops-nix = { @@ -29,6 +33,7 @@ home-manager, microvm, nix-darwin, + nixos-generators, nixos-hardware, nixpkgs, sops-nix, @@ -43,32 +48,41 @@ }; }) // (let - mapMachineConfigurations = nixpkgs.lib.mapAttrs (host: configuration: - configuration.builder ( - let - hmConfiguration = dotfiles.rawHomeManagerConfigurations."${configuration.user}@${host}"; - in { - inherit (configuration) system; - modules = - configuration.modules - ++ [ - {nixpkgs.config.allowUnfree = true;} - { - home-manager = { - users.${configuration.user} = import ./dotfiles/home.nix { - inherit home-manager; - inherit (hmConfiguration) system username homeDirectory stateVersion profile mainlyRemote; - }; - useGlobalPkgs = true; - }; - } - ]; - } - )); + mapMachineConfigurations = nixpkgs.lib.mapAttrs ( + host: configuration: + configuration.builder ( + let + hmConfiguration = dotfiles.rawHomeManagerConfigurations."${configuration.user}@${host}"; + in + { + inherit (configuration) system; + modules = + configuration.modules + ++ [ + {nixpkgs.config.allowUnfree = true;} + { + home-manager = { + users.${configuration.user} = import ./dotfiles/home.nix { + inherit home-manager; + inherit (hmConfiguration) system username homeDirectory stateVersion profile mainlyRemote; + }; + useGlobalPkgs = true; + }; + } + ]; + } + // ( + if configuration.builderArgs == null + then {} + else configuration.builderArgs + ) + ) + ); in { darwinConfigurations = mapMachineConfigurations { "Rafaels-Air" = { builder = nix-darwin.lib.darwinSystem; + builderArgs = null; system = "aarch64-darwin"; user = "ereslibre"; modules = [ @@ -79,17 +93,23 @@ }; nixosConfigurations = mapMachineConfigurations { "devbox" = { - builder = nixpkgs.lib.nixosSystem; + builder = nixos-generators.nixosGenerate; + builderArgs = rec { + system = "aarch64-linux"; + format = "qcow"; + specialArgs.diskSize = "102400"; + }; system = "aarch64-linux"; user = "ereslibre"; modules = [ + {nix.registry.nixpkgs.flake = nixpkgs;} home-manager.nixosModules.home-manager ./devbox/configuration.nix - "${nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-base.nix" ]; }; "hulk" = { builder = nixpkgs.lib.nixosSystem; + builderArgs = null; system = "x86_64-linux"; user = "ereslibre"; modules = [ @@ -100,6 +120,7 @@ }; "nuc-1" = { builder = nixpkgs.lib.nixosSystem; + builderArgs = null; system = "x86_64-linux"; user = "ereslibre"; modules = [ @@ -111,6 +132,7 @@ }; "nuc-2" = { builder = nixpkgs.lib.nixosSystem; + builderArgs = null; system = "x86_64-linux"; user = "ereslibre"; modules = [ @@ -122,6 +144,7 @@ }; "nuc-3" = { builder = nixpkgs.lib.nixosSystem; + builderArgs = null; system = "x86_64-linux"; user = "ereslibre"; modules = [ @@ -133,6 +156,7 @@ }; "pi-desktop" = { builder = nixpkgs.lib.nixosSystem; + builderArgs = null; system = "aarch64-linux"; user = "ereslibre"; modules = [ diff --git a/justfile b/justfile index b707e500..00619560 100644 --- a/justfile +++ b/justfile @@ -1,4 +1,5 @@ defaultHost := "$(hostname -s)" +defaultQcowHost := "devbox" switch host=defaultHost: @./.switch.sh {{host}} @@ -6,8 +7,8 @@ switch host=defaultHost: build host=defaultHost: nix build .#nixosConfigurations.{{host}}.config.system.build.toplevel -build-iso host=defaultHost: - nix build --impure .#nixosConfigurations.{{host}}.config.system.build.isoImage +qcow host=defaultQcowHost: + nix build --impure .#nixosConfigurations.{{host}} fmt: find . -name "*.nix" | xargs nix develop --command alejandra