mirror of
https://github.com/moons-14/dotfiles.git
synced 2026-10-06 00:58:12 +09:00
nix registory
This commit is contained in:
+3
@@ -0,0 +1,3 @@
|
||||
{
|
||||
includes = [ "applications.missing" ];
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
imports = [ ];
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
{
|
||||
system.stateVersion = 6;
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
{
|
||||
fileSystems."/" = {
|
||||
device = "/dev/null";
|
||||
fsType = "ext4";
|
||||
};
|
||||
|
||||
boot.loader.grub.enable = false;
|
||||
system.stateVersion = "26.05";
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
marker ? "host",
|
||||
...
|
||||
}:
|
||||
{
|
||||
test.systemValues = [ "common:${marker}" ];
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
test.systemValues = [ "darwin" ];
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
test.homeValues = [ "home" ];
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
{ lib, ... }:
|
||||
{
|
||||
description = "alpha test application";
|
||||
|
||||
includes = [ "services.nested" ];
|
||||
|
||||
imports.nixos = [
|
||||
{
|
||||
options.test = {
|
||||
external = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "external-default";
|
||||
};
|
||||
systemValues = lib.mkOption {
|
||||
type = lib.types.listOf lib.types.str;
|
||||
default = [ ];
|
||||
};
|
||||
};
|
||||
}
|
||||
];
|
||||
|
||||
imports.darwin = [
|
||||
{
|
||||
options.test.systemValues = lib.mkOption {
|
||||
type = lib.types.listOf lib.types.str;
|
||||
default = [ ];
|
||||
};
|
||||
}
|
||||
];
|
||||
|
||||
imports.home = [
|
||||
{
|
||||
options.test.homeValues = lib.mkOption {
|
||||
type = lib.types.listOf lib.types.str;
|
||||
default = [ ];
|
||||
};
|
||||
}
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
test.systemValues = [ "nixos" ];
|
||||
test.external = "set-by-nixos-fragment";
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
test.homeValues = [ "beta-home" ];
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
thisFileMustNotBeDiscovered = true;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
includes = [
|
||||
"applications.alpha"
|
||||
"applications.beta"
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
{ lib, ... }:
|
||||
{
|
||||
imports.nixos = [
|
||||
{
|
||||
options.test.nested = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
};
|
||||
}
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
test.nested = true;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
home = {
|
||||
username = "test";
|
||||
homeDirectory = if pkgs.stdenv.hostPlatform.isDarwin then "/Users/test" else "/home/test";
|
||||
stateVersion = "26.05";
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
{
|
||||
inputs,
|
||||
lib,
|
||||
pkgs,
|
||||
}:
|
||||
let
|
||||
registry = import ../libs/registry.nix {
|
||||
inherit inputs lib;
|
||||
modulesRoot = ./fixtures/registry/modules;
|
||||
};
|
||||
|
||||
hostLib = import ../libs/hosts.nix {
|
||||
inherit inputs lib registry;
|
||||
};
|
||||
|
||||
baseModule = {
|
||||
options = {
|
||||
home = {
|
||||
username = lib.mkOption { type = lib.types.str; };
|
||||
homeDirectory = lib.mkOption { type = lib.types.str; };
|
||||
stateVersion = lib.mkOption { type = lib.types.str; };
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
eval =
|
||||
class: selected:
|
||||
lib.evalModules {
|
||||
specialArgs = {
|
||||
inherit pkgs;
|
||||
marker = "special-arg";
|
||||
};
|
||||
modules = [
|
||||
baseModule
|
||||
(registry.mkModule { inherit class; })
|
||||
(registry.mkSelectionModule selected)
|
||||
];
|
||||
};
|
||||
|
||||
nixos = eval "nixos" [ "profiles.interface.test" ];
|
||||
darwin = eval "darwin" [ "applications.alpha" ];
|
||||
home = eval "home" [ "profiles.interface.test" ];
|
||||
|
||||
nixosHost = hostLib.mkNixos "registry-test" {
|
||||
system = "x86_64-linux";
|
||||
user = "test";
|
||||
path = ./fixtures/registry/hosts;
|
||||
profiles = [ "interface.test" ];
|
||||
};
|
||||
|
||||
darwinHost = hostLib.mkDarwin "registry-test-darwin" {
|
||||
system = "aarch64-darwin";
|
||||
user = "test";
|
||||
path = ./fixtures/registry/hosts;
|
||||
applications = [ "alpha" ];
|
||||
};
|
||||
|
||||
missingUnit = builtins.tryEval (
|
||||
builtins.deepSeq (registry.validateUnitIds [ "applications.missing" ]) true
|
||||
);
|
||||
|
||||
invalidDependencyRegistry = import ../libs/registry.nix {
|
||||
inherit inputs lib;
|
||||
modulesRoot = ./fixtures/registry-invalid-dependency/modules;
|
||||
};
|
||||
missingDependency = builtins.tryEval (builtins.deepSeq invalidDependencyRegistry.unitIds true);
|
||||
|
||||
invalidFragmentRegistry = import ../libs/registry.nix {
|
||||
inherit inputs lib;
|
||||
modulesRoot = ./fixtures/registry-invalid-fragment/modules;
|
||||
};
|
||||
invalidFragmentEvaluation = lib.evalModules {
|
||||
modules = [
|
||||
(invalidFragmentRegistry.mkModule { class = "home"; })
|
||||
(invalidFragmentRegistry.mkSelectionModule [ "applications.broken" ])
|
||||
];
|
||||
};
|
||||
invalidFragment = builtins.tryEval (builtins.deepSeq invalidFragmentEvaluation.config true);
|
||||
|
||||
assertions =
|
||||
assert
|
||||
registry.unitIds == [
|
||||
"applications.alpha"
|
||||
"applications.beta"
|
||||
"profiles.interface.test"
|
||||
"services.nested"
|
||||
"users.test"
|
||||
];
|
||||
assert !(builtins.elem "namespace" registry.unitIds);
|
||||
assert nixos.config.my.profiles.interface.test.enable;
|
||||
assert nixos.config.my.applications.alpha.enable;
|
||||
assert nixos.config.my.applications.beta.enable;
|
||||
assert nixos.config.my.services.nested.enable;
|
||||
assert nixos.config.test.nested;
|
||||
assert
|
||||
nixos.config.test.systemValues == [
|
||||
"common:special-arg"
|
||||
"nixos"
|
||||
];
|
||||
assert nixos.config.test.external == "set-by-nixos-fragment";
|
||||
assert
|
||||
darwin.config.test.systemValues == [
|
||||
"common:special-arg"
|
||||
"darwin"
|
||||
];
|
||||
assert
|
||||
home.config.test.homeValues == [
|
||||
"home"
|
||||
"beta-home"
|
||||
];
|
||||
assert nixosHost.config.my.profiles.interface.test.enable;
|
||||
assert nixosHost.config.home-manager.users.test.my.applications.alpha.enable;
|
||||
assert
|
||||
nixosHost.config.home-manager.users.test.test.homeValues == [
|
||||
"home"
|
||||
"beta-home"
|
||||
];
|
||||
assert darwinHost.config.my.applications.alpha.enable;
|
||||
assert darwinHost.config.home-manager.users.test.my.applications.alpha.enable;
|
||||
assert darwinHost.config.home-manager.users.test.test.homeValues == [ "home" ];
|
||||
assert
|
||||
darwinHost.config.test.systemValues == [
|
||||
"common:host"
|
||||
"darwin"
|
||||
];
|
||||
assert !missingUnit.success;
|
||||
assert !missingDependency.success;
|
||||
assert !invalidFragment.success;
|
||||
true;
|
||||
in
|
||||
assert assertions;
|
||||
pkgs.runCommand "unit-registry-evaluation-tests" { } ''
|
||||
touch "$out"
|
||||
''
|
||||
Reference in New Issue
Block a user