Skip to content
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
3 changes: 2 additions & 1 deletion common/modules/network-boot/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ in
interfaces = lib.mkOption {
type = lib.types.listOf (lib.types.attrsOf lib.types.str);
description = "Network interface configurations";
default = [ ];
example = [
{
interface = "enp4s0";
Expand All @@ -58,7 +59,7 @@ in
};

username = lib.mkOption {
type = lib.types.str;
type = lib.types.nullOr lib.types.str;
description = "Username that is the owner of all files in the tftproot directory";
example = "myuser";
default = null;
Expand Down
22 changes: 15 additions & 7 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@
# overlays, I drop the "pkgs" parameter of the perSystem function
# and initialize it manually.
pkgs = initNixpkgs inputs.nixpkgs system (builtins.attrValues self.overlays);
pkgsUnstable = initNixpkgs inputs.nixpkgs-unstable system (builtins.attrValues self.overlays);

commonNix = {
# All unit and integration tests as combined derivation.
Expand Down Expand Up @@ -219,14 +220,21 @@

formatter = pkgs.nixfmt-rfc-style;

# Everything under packages can also be run. So I don't quite get
# the difference. So, I do not provide the `apps` key for now.
# Exported (and runnable) packages.
#
# $ nix build .\#packages.x86_64-linux.<attribute-name>
# $ nix run .\#<attribute-name>
packages = commonNix.packages // {
listNixosOptions = pkgs.callPackage ./utils/list-nixos-options.nix inputs;
};
# $ nix build|run .\#packages.x86_64-linux.<attribute-name>
# $ nix build|run .\#<attribute-name>
packages =
let
listNixosOptions = pkgs.callPackage ./utils/list-nixos-options.nix {
inherit (inputs) self;
inherit (pkgsUnstable) nixos-option;
};
in
commonNix.packages
// {
inherit listNixosOptions;
};
};
};
}
35 changes: 2 additions & 33 deletions utils/list-nixos-options.nix
Original file line number Diff line number Diff line change
@@ -1,46 +1,17 @@
# Lists all NixOS options of the common NixOS modules.

{
home-manager,
nixpkgs,
self,

ansi,
lib,
nixos-option,
writeShellScriptBin,
writeText,
...
}:

let
selfModules = builtins.attrValues self.nixosModules;
# This add structure is caused by flake-parts.
extractModulePath =
module: builtins.head (builtins.head (builtins.head module.imports).imports).imports;
toModuleImportLine = module: "(import ${extractModulePath module})";
combinedConfig = writeText "combined-config" ''
{
imports = [
# Pre-reququisites
(import ${home-manager}/nixos)
${builtins.concatStringsSep "\n" (map toModuleImportLine selfModules)}
];

# Activate all default options
phip1611.bootitems.enable = true;
phip1611.common.system.enable = true;
phip1611.common.user-env.enable = true;
phip1611.network-boot.enable = true;

# Remove some used but not defined errors.
phip1611.common.user-env.username = "foobar123";
phip1611.common.user-env.git.email = "phip1611n@gmail.com";
phip1611.common.user-env.git.username = "Philipp Schuster";
phip1611.network-boot.username = "foobar123";
phip1611.network-boot.interfaces = [];
}
'';
DEFAULT_HOST = "homepc";
in
writeShellScriptBin "list-common-nixos-options" ''
export PATH="${
Expand All @@ -49,11 +20,9 @@ writeShellScriptBin "list-common-nixos-options" ''
nixos-option
]
}:$PATH"
export NIX_PATH="nixpkgs=${nixpkgs}"
export NIXOS_CONFIG=${combinedConfig}

echo -ne "$(ansi bold)Printing all configuration options of the phip1611 common module$(ansi reset) "
echo -e "$(ansi bold)with their default value:$(ansi reset)"

nixos-option phip1611 -r
nixos-option --flake ${self}#${DEFAULT_HOST} phip1611 -r
''