host: add deault implementation for system.build.isoImage target (per host)

This commit is contained in:
David Arnold 2021-01-25 16:48:51 -05:00
parent 5e2f4d09ef
commit 28ccf4f3f9
No known key found for this signature in database
GPG Key ID: 6D6A936E69C59D08
4 changed files with 37 additions and 19 deletions

View File

@ -170,10 +170,9 @@ nix build ./#homeConfigurations.NixOS.nixos.home.activationPackage
## Build an ISO ## Build an ISO
You can make an ISO and customize it by modifying the [niximg](./hosts/niximg.nix) You can make an ISO out of any config:
file:
```sh ```sh
flk iso flk iso yourConfig # build an iso for hosts/yourConfig.nix
``` ```
## Hardware Specific Profile for a Single Host ## Hardware Specific Profile for a Single Host

View File

@ -15,8 +15,40 @@ let
unstableModules = [ ]; unstableModules = [ ];
addToDisabledModules = [ ]; addToDisabledModules = [ ];
libExt = lib.extend (
final: prev: {
nixosSystemExtended = { modules, ... } @ args:
lib.nixosSystem (args // {
modules =
let
isoConfig = (
import (nixos + "/nixos/lib/eval-config.nix")
(
args // {
modules = modules ++ [
(nixos + "/nixos/modules/installer/cd-dvd/installation-cd-minimal-new-kernel.nix")
({ config, ... }: {
isoImage.isoBaseName = "nixos-" + config.networking.hostName;
})
];
}
)
).config;
in
modules ++ [
{
system.build = {
iso = isoConfig.system.build.isoImage;
};
}
];
}
);
}
);
config = hostName: config = hostName:
lib.nixosSystem { libExt.nixosSystemExtended {
inherit system; inherit system;
specialArgs = specialArgs =

View File

@ -1,13 +0,0 @@
{ unstableModulesPath, ... }: {
imports = [
# passwd is nixos by default
../users/nixos
# passwd is empty by default
../users/root
"${unstableModulesPath}/installer/cd-dvd/iso-image.nix"
];
isoImage.makeEfiBootable = true;
isoImage.makeUsbBootable = true;
networking.networkmanager.enable = true;
}

View File

@ -12,7 +12,7 @@ let
flk = pkgs.writeShellScriptBin "flk" '' flk = pkgs.writeShellScriptBin "flk" ''
if [[ -z "$1" ]]; then if [[ -z "$1" ]]; then
echo "Usage: $(basename "$0") [ iso | up | install {host} | {host} [switch|boot|test] | home {host} {user} [switch] ]" echo "Usage: $(basename "$0") [ up | iso {host} | install {host} | {host} [switch|boot|test] | home {host} {user} [switch] ]"
elif [[ "$1" == "up" ]]; then elif [[ "$1" == "up" ]]; then
mkdir -p $DEVSHELL_ROOT/up mkdir -p $DEVSHELL_ROOT/up
hostname=$(hostname) hostname=$(hostname)
@ -24,7 +24,7 @@ let
git add -f $DEVSHELL_ROOT/up/$hostname git add -f $DEVSHELL_ROOT/up/$hostname
git add -f $DEVSHELL_ROOT/hosts/up-$hostname.nix git add -f $DEVSHELL_ROOT/hosts/up-$hostname.nix
elif [[ "$1" == "iso" ]]; then elif [[ "$1" == "iso" ]]; then
nix build $DEVSHELL_ROOT#nixosConfigurations.niximg.${build}.isoImage "${"\${@:2}"}" nix build $DEVSHELL_ROOT#nixosConfigurations.$2.${build}.iso "${"\${@:3}"}"
elif [[ "$1" == "install" ]]; then elif [[ "$1" == "install" ]]; then
sudo nixos-install --flake "$DEVSHELL_ROOT#$2" "${"\${@:3}"}" sudo nixos-install --flake "$DEVSHELL_ROOT#$2" "${"\${@:3}"}"
elif [[ "$1" == "home" ]]; then elif [[ "$1" == "home" ]]; then