Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

host: add deault implementation for system.build.isoImage target (per… #102

Merged
merged 4 commits into from
Feb 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,9 @@ nix build ./#homeConfigurations.NixOS.nixos.home.activationPackage

## Build an ISO

You can make an ISO and customize it by modifying the [niximg](./hosts/niximg.nix)
file:
You can make an ISO out of any config:
```sh
flk iso
flk iso yourConfig # build an iso for hosts/yourConfig.nix
```

## Hardware Specific Profile for a Single Host
Expand Down
4 changes: 1 addition & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@

overlay = import ./pkgs;

lib = import ./lib {
inherit (nixos) lib;
};
lib = import ./lib { inherit nixos; };

templates.flk.path = ./.;

Expand Down
4 changes: 2 additions & 2 deletions hosts/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
, ...
}:
let
inherit (lib.flk) recImport;
inherit (lib.flk) recImport nixosSystemExtended;
inherit (builtins) attrValues removeAttrs;

unstableModules = [ ];
addToDisabledModules = [ ];

config = hostName:
lib.nixosSystem {
nixosSystemExtended {
inherit system;

specialArgs =
Expand Down
13 changes: 0 additions & 13 deletions hosts/niximg.nix

This file was deleted.

34 changes: 31 additions & 3 deletions lib/default.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{ lib, ... }:
{ nixos, ... }:
let
inherit (builtins) attrNames attrValues isAttrs readDir listToAttrs mapAttrs;

inherit (lib) fold filterAttrs hasSuffix mapAttrs' nameValuePair removeSuffix
recursiveUpdate genAttrs;
inherit (nixos.lib) fold filterAttrs hasSuffix mapAttrs' nameValuePair removeSuffix
recursiveUpdate genAttrs nixosSystem mkForce;

# mapFilterAttrs ::
# (name -> value -> bool )
Expand Down Expand Up @@ -55,6 +55,34 @@ in
nameValuePair ("") (null))
(readDir dir);

nixosSystemExtended = { modules, ... } @ args:
nixosSystem (args // {
modules =
let
modpath = "nixos/modules";
cd = "installer/cd-dvd/installation-cd-minimal-new-kernel.nix";
isoConfig = (nixosSystem
(args // {
modules = modules ++ [
"${nixos}/${modpath}/${cd}"
({ config, ... }: {
isoImage.isoBaseName = "nixos-" + config.networking.hostName;
# confilcts with networking.wireless which might be slightly
# more useful on a stick
networking.networkmanager.enable = mkForce false;
# confilcts with networking.wireless
networking.wireless.iwd.enable = mkForce false;
})
];
})).config;
in
modules ++ [{
system.build = {
iso = isoConfig.system.build.isoImage;
};
}];
});

nixosModules =
let
# binary cache
Expand Down
4 changes: 2 additions & 2 deletions shell/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ let

flk = pkgs.writeShellScriptBin "flk" ''
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
mkdir -p $DEVSHELL_ROOT/up
hostname=$(hostname)
Expand All @@ -24,7 +24,7 @@ let
git add -f $DEVSHELL_ROOT/up/$hostname
git add -f $DEVSHELL_ROOT/hosts/up-$hostname.nix
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
sudo nixos-install --flake "$DEVSHELL_ROOT#$2" "${"\${@:3}"}"
elif [[ "$1" == "home" ]]; then
Expand Down