From a4fca57ff75b0294e24fbe43ace6abbe7c47d219 Mon Sep 17 00:00:00 2001 From: SebastianStork Date: Fri, 16 Aug 2024 21:38:40 +0200 Subject: [PATCH] Create custom iso --- .gitignore | 3 ++- flake.lock | 37 +++++++++++++++++++++++++++++++++++++ flake.nix | 5 +++++ flake/hosts.nix | 7 +++++++ hosts/installer/default.nix | 28 ++++++++++++++++++++++++++++ justfile | 3 +++ 6 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 hosts/installer/default.nix diff --git a/.gitignore b/.gitignore index 00c1844..3246186 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -.direnv/ \ No newline at end of file +.direnv/ +result/ \ No newline at end of file diff --git a/flake.lock b/flake.lock index 576d641..7581814 100644 --- a/flake.lock +++ b/flake.lock @@ -188,6 +188,42 @@ "type": "github" } }, + "nixlib": { + "locked": { + "lastModified": 1723337705, + "narHash": "sha256-znSU0DeNDPt7+LMAfFkvKloMaeQ6yl/U5SqV/ktl1vA=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "ace7856d327b618d3777e31b1f224b3ab57ed71a", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "nixos-generators": { + "inputs": { + "nixlib": "nixlib", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1723683171, + "narHash": "sha256-hQMQQHOVVkiCO5hmbjI3EVimWFIkRNkGIGUhyIQ0mQ0=", + "owner": "nix-community", + "repo": "nixos-generators", + "rev": "1cb3dc2f3af215ea40911de8fd0942c1ff3fb673", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixos-generators", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1723362943, @@ -241,6 +277,7 @@ "home-manager": "home-manager", "nix-index-database": "nix-index-database", "nix-vscode-extensions": "nix-vscode-extensions", + "nixos-generators": "nixos-generators", "nixpkgs": "nixpkgs", "sops-nix": "sops-nix", "treefmt-nix": "treefmt-nix", diff --git a/flake.nix b/flake.nix index f99f76c..eb30b46 100644 --- a/flake.nix +++ b/flake.nix @@ -4,6 +4,11 @@ flake-parts.url = "github:hercules-ci/flake-parts"; + nixos-generators = { + url = "github:nix-community/nixos-generators"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + home-manager = { url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgs"; diff --git a/flake/hosts.nix b/flake/hosts.nix index d9b00a8..4f63a74 100644 --- a/flake/hosts.nix +++ b/flake/hosts.nix @@ -19,5 +19,12 @@ in inherit specialArgs; modules = modulesOf "inspiron"; }; + installer = inputs.nixpkgs.lib.nixosSystem { + inherit specialArgs; + modules = [ + { networking.hostName = "installer"; } + "${self}/hosts/installer" + ]; + }; }; } diff --git a/hosts/installer/default.nix b/hosts/installer/default.nix new file mode 100644 index 0000000..1c3d819 --- /dev/null +++ b/hosts/installer/default.nix @@ -0,0 +1,28 @@ +{ + modulesPath, + inputs, + pkgs, + lib, + ... +}: +{ + imports = [ + inputs.nixos-generators.nixosModules.all-formats + "${modulesPath}/installer/cd-dvd/installation-cd-minimal.nix" + ../common.nix + ]; + + nixpkgs.hostPlatform = "x86_64-linux"; + + environment.systemPackages = [ inputs.disko.packages.${pkgs.system}.default ]; + + users.users.root.openssh.authorizedKeys.keys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGBUORYC3AvTPQmtUEApTa9DvHoJy4mjuQy8abSjCcDd seb@north" + ]; + + installer.cloneConfig = lib.mkForce false; + isoImage = { + edition = lib.mkForce "seb-minimal"; + isoName = lib.mkForce "NixOS"; + }; +} diff --git a/justfile b/justfile index d7e0f52..e635c85 100644 --- a/justfile +++ b/justfile @@ -25,3 +25,6 @@ fmt: check: nix flake check + +build-iso: + nix build .#nixosConfigurations.installer.config.formats.iso -o result