Compare commits
No commits in common. "d281a23a8a4f587638dce9abe71fc1e1f812ff44" and "72f2a2ddc0c85376ffa5ad10526b8eb00fc8daf4" have entirely different histories.
d281a23a8a
...
72f2a2ddc0
19 changed files with 164 additions and 378 deletions
|
|
@ -1,6 +1,3 @@
|
||||||
{ ... }@flake:
|
{ ... }@flake: { ... }@inputs: { ... }@imports: {
|
||||||
{ ... }@inputs:
|
imports = builtins.attrValues (flake.hmModules or {});
|
||||||
{ ... }@imports:
|
|
||||||
{
|
|
||||||
imports = builtins.attrValues (flake.hmModules or { });
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,4 @@
|
||||||
flake:
|
flake: { ... }@inputs: { ... }@imports: let
|
||||||
{ ... }@inputs:
|
|
||||||
{ ... }@imports:
|
|
||||||
let
|
|
||||||
module' = name: imports: builtins.trace "user module: ${name}" { inherit imports; };
|
module' = name: imports: builtins.trace "user module: ${name}" { inherit imports; };
|
||||||
modules = builtins.mapAttrs module' imports."user/module";
|
modules = builtins.mapAttrs module' imports."user/module";
|
||||||
in
|
in { default = module' "default" (builtins.attrValues modules); } // modules
|
||||||
{ default = module' "default" (builtins.attrValues modules); } // modules
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,4 @@
|
||||||
{ ... }@flake:
|
{ ... }@flake: { ... }@inputs: { profile, ... }@imports: let
|
||||||
{ ... }@inputs:
|
|
||||||
{ profile, ... }@imports:
|
|
||||||
let
|
|
||||||
profile' = name: snippets: builtins.trace "home-manager: profile: ${name}" { imports = snippets; };
|
profile' = name: snippets: builtins.trace "home-manager: profile: ${name}" { imports = snippets; };
|
||||||
in
|
in builtins.mapAttrs profile' profile
|
||||||
builtins.mapAttrs profile' profile
|
|
||||||
|
|
|
||||||
|
|
@ -1,50 +1,32 @@
|
||||||
{
|
{ nixosUsers ? {}, nixosGroups ? {}, nixosModules, hmModules ? { default = {}; }, ...}@flake: { ... }@inputs: { host, ... }@imports: let
|
||||||
nixosUsers ? { },
|
host' = name: snippets: let
|
||||||
nixosGroups ? { },
|
|
||||||
nixosModules,
|
|
||||||
hmModules ? {
|
|
||||||
default = { };
|
|
||||||
},
|
|
||||||
...
|
|
||||||
}@flake:
|
|
||||||
{ ... }@inputs:
|
|
||||||
{ host, ... }@imports:
|
|
||||||
let
|
|
||||||
host' =
|
|
||||||
name: snippets:
|
|
||||||
let
|
|
||||||
|
|
||||||
overlay = self: super: {
|
overlay = self: super: {
|
||||||
makeModulesClosure = x: super.makeModulesClosure (x // { allowMissing = true; });
|
makeModulesClosure = x: super.makeModulesClosure (x // { allowMissing = true; });
|
||||||
|
};
|
||||||
|
|
||||||
|
common = { modulesPath, lib, ... }: {
|
||||||
|
config.nixpkgs.overlays = [ overlay ];
|
||||||
|
config.networking.hostName = lib.mkForce name;
|
||||||
|
config.home-manager = {
|
||||||
|
sharedModules = [ hmModules.default ] ;
|
||||||
};
|
};
|
||||||
|
|
||||||
common =
|
imports = [
|
||||||
{ modulesPath, lib, ... }:
|
(modulesPath + "/installer/cd-dvd/installation-cd-minimal-new-kernel-no-zfs.nix")
|
||||||
{
|
nixosModules.default
|
||||||
config.nixpkgs.overlays = [ overlay ];
|
inputs.home-manager.nixosModules.default
|
||||||
config.networking.hostName = lib.mkForce name;
|
];
|
||||||
config.home-manager = {
|
};
|
||||||
sharedModules = [ hmModules.default ];
|
|
||||||
};
|
|
||||||
|
|
||||||
imports = [
|
system = inputs.nixpkgs.lib.nixosSystem {
|
||||||
(modulesPath + "/installer/cd-dvd/installation-cd-minimal-new-kernel-no-zfs.nix")
|
specialArgs = { inherit inputs flake; };
|
||||||
nixosModules.default
|
modules = [ common ]
|
||||||
inputs.home-manager.nixosModules.default
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
system = inputs.nixpkgs.lib.nixosSystem {
|
|
||||||
specialArgs = { inherit inputs flake; };
|
|
||||||
modules = [
|
|
||||||
common
|
|
||||||
]
|
|
||||||
++ snippets
|
++ snippets
|
||||||
++ builtins.attrValues nixosUsers
|
++ builtins.attrValues nixosUsers
|
||||||
++ builtins.attrValues nixosGroups;
|
++ builtins.attrValues nixosGroups
|
||||||
};
|
;
|
||||||
in
|
};
|
||||||
system.config.system.build.isoImage;
|
in system.config.system.build.isoImage;
|
||||||
|
|
||||||
in
|
in builtins.mapAttrs host' host
|
||||||
builtins.mapAttrs host' host
|
|
||||||
|
|
|
||||||
|
|
@ -1,45 +1,19 @@
|
||||||
{
|
{ nixosUsers ? {}, nixosGroups ? {}, nixosModules, hmModules ? { default = {}; }, ...}@flake: { ... }@inputs: { host, ... }@imports: let
|
||||||
nixosUsers ? { },
|
system = hostname: { namespace ? "fbs42", nixpkgs ? "nixpkgs" }: inputs.${nixpkgs}.lib.nixosSystem {
|
||||||
nixosGroups ? { },
|
specialArgs = { inherit inputs flake namespace; };
|
||||||
nixosModules,
|
modules = builtins.concatLists (map (base: builtins.attrValues (flake.lib.scan { base = "${base}/host/${hostname}"; })) flake.lib.schema.base)
|
||||||
hmModules ? {
|
++ [ { config.networking.hostName = hostname; } ]
|
||||||
default = { };
|
++ [ nixosModules.default ]
|
||||||
},
|
++ inputs.${nixpkgs}.lib.optional (inputs ? home-manager) {
|
||||||
...
|
imports = [ inputs.home-manager.nixosModules.default ];
|
||||||
}@flake:
|
config.home-manager = {
|
||||||
{ ... }@inputs:
|
sharedModules = [ hmModules.default ];
|
||||||
{ host, ... }@imports:
|
extraSpecialArgs = { inherit flake namespace; };
|
||||||
let
|
};
|
||||||
system =
|
}
|
||||||
hostname:
|
++ builtins.attrValues nixosUsers
|
||||||
{
|
++ builtins.attrValues nixosGroups
|
||||||
namespace ? "fbs42",
|
;
|
||||||
nixpkgs ? "nixpkgs",
|
};
|
||||||
}:
|
|
||||||
inputs.${nixpkgs}.lib.nixosSystem {
|
|
||||||
specialArgs = { inherit inputs flake namespace; };
|
|
||||||
modules =
|
|
||||||
builtins.concatLists (
|
|
||||||
map (
|
|
||||||
base: builtins.attrValues (flake.lib.scan { base = "${base}/host/${hostname}"; })
|
|
||||||
) flake.lib.schema.base
|
|
||||||
)
|
|
||||||
++ [ { config.networking.hostName = hostname; } ]
|
|
||||||
++ [ nixosModules.default ]
|
|
||||||
++ inputs.${nixpkgs}.lib.optional (inputs ? home-manager) {
|
|
||||||
imports = [ inputs.home-manager.nixosModules.default ];
|
|
||||||
config.home-manager = {
|
|
||||||
sharedModules = [ hmModules.default ];
|
|
||||||
extraSpecialArgs = { inherit flake namespace; };
|
|
||||||
};
|
|
||||||
}
|
|
||||||
++ builtins.attrValues nixosUsers
|
|
||||||
++ builtins.attrValues nixosGroups;
|
|
||||||
};
|
|
||||||
|
|
||||||
in
|
in builtins.mapAttrs (name: value: assert builtins.length value == 1; system name (builtins.head value)) host
|
||||||
builtins.mapAttrs (
|
|
||||||
name: value:
|
|
||||||
assert builtins.length value == 1;
|
|
||||||
system name (builtins.head value)
|
|
||||||
) host
|
|
||||||
|
|
|
||||||
|
|
@ -1,25 +1,10 @@
|
||||||
flake:
|
flake: { ... }@inputs: { group, ... }@imports: let
|
||||||
{ ... }@inputs:
|
group' = name: snippets: { pkgs, lib, options, config, ... }@args: let
|
||||||
{ group, ... }@imports:
|
invoke = x: if builtins.isFunction x then x args else x;
|
||||||
let
|
in {
|
||||||
group' =
|
options.fbs42.group.${name} = lib.mkEnableOption name;
|
||||||
name: snippets:
|
config.users.groups.${name} = lib.mkIf
|
||||||
{
|
(config.fbs42.group.${name} || builtins.any (usr: usr.group == name) (builtins.attrValues config.users.users))
|
||||||
pkgs,
|
(lib.mkMerge (map invoke snippets));
|
||||||
lib,
|
};
|
||||||
options,
|
in builtins.mapAttrs group' group
|
||||||
config,
|
|
||||||
...
|
|
||||||
}@args:
|
|
||||||
let
|
|
||||||
invoke = x: if builtins.isFunction x then x args else x;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
options.fbs42.group.${name} = lib.mkEnableOption name;
|
|
||||||
config.users.groups.${name} = lib.mkIf (
|
|
||||||
config.fbs42.group.${name}
|
|
||||||
|| builtins.any (usr: usr.group == name) (builtins.attrValues config.users.users)
|
|
||||||
) (lib.mkMerge (map invoke snippets));
|
|
||||||
};
|
|
||||||
in
|
|
||||||
builtins.mapAttrs group' group
|
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,3 @@
|
||||||
flake:
|
flake: { ... }@inputs: { module, ... }@imports: let
|
||||||
{ ... }@inputs:
|
modules = builtins.mapAttrs (name: imports: builtins.trace "module: ${name}" { inherit imports; }) module;
|
||||||
{ module, ... }@imports:
|
in { default = { imports = builtins.attrValues modules; }; } // modules
|
||||||
let
|
|
||||||
modules = builtins.mapAttrs (
|
|
||||||
name: imports: builtins.trace "module: ${name}" { inherit imports; }
|
|
||||||
) module;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
default = {
|
|
||||||
imports = builtins.attrValues modules;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
// modules
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,2 @@
|
||||||
{ ... }@flake:
|
{ ... }@flake: { ... }@inputs: { profile, ... }@imports:
|
||||||
{ ... }@inputs:
|
builtins.mapAttrs (name: imports: builtins.trace "profile: ${name}" { inherit imports; }) profile
|
||||||
{ profile, ... }@imports:
|
|
||||||
builtins.mapAttrs (name: imports: builtins.trace "profile: ${name}" { inherit imports; }) profile
|
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,5 @@
|
||||||
self:
|
self: { ... }@inputs: { user, ... }@imports: let
|
||||||
{ ... }@inputs:
|
user' = name: snippets: { pkgs, lib, config, ... }@args:
|
||||||
{ user, ... }@imports:
|
|
||||||
let
|
|
||||||
user' =
|
|
||||||
name: snippets:
|
|
||||||
{
|
|
||||||
pkgs,
|
|
||||||
lib,
|
|
||||||
config,
|
|
||||||
...
|
|
||||||
}@args:
|
|
||||||
builtins.trace "user: ${name}" {
|
builtins.trace "user: ${name}" {
|
||||||
options.fbs42.user.${name} = lib.mkEnableOption name;
|
options.fbs42.user.${name} = lib.mkEnableOption name;
|
||||||
## no longer with nixos-24.11
|
## no longer with nixos-24.11
|
||||||
|
|
@ -17,15 +7,11 @@ let
|
||||||
# group = lib.mkDefault name;
|
# group = lib.mkDefault name;
|
||||||
#};
|
#};
|
||||||
|
|
||||||
imports = map (
|
imports = map ({ user, home-manager}: {
|
||||||
{ user, home-manager }:
|
config = lib.mkIf config.fbs42.user.${name} {
|
||||||
{
|
users.users.${name} = (user args);
|
||||||
config = lib.mkIf config.fbs42.user.${name} {
|
home-manager.users.${name} = home-manager;
|
||||||
users.users.${name} = (user args);
|
};
|
||||||
home-manager.users.${name} = home-manager;
|
}) snippets;
|
||||||
};
|
|
||||||
}
|
|
||||||
) snippets;
|
|
||||||
};
|
};
|
||||||
in
|
in builtins.mapAttrs user' user
|
||||||
builtins.mapAttrs user' user
|
|
||||||
|
|
|
||||||
|
|
@ -1,52 +1,34 @@
|
||||||
{
|
{ nixosUsers ? {}, nixosGroups ? {}, nixosModules, hmModules ? { default = {}; }, ...}@flake: { ... }@inputs: { host, ... }@imports: let
|
||||||
nixosUsers ? { },
|
host' = name: snippets: let
|
||||||
nixosGroups ? { },
|
|
||||||
nixosModules,
|
|
||||||
hmModules ? {
|
|
||||||
default = { };
|
|
||||||
},
|
|
||||||
...
|
|
||||||
}@flake:
|
|
||||||
{ ... }@inputs:
|
|
||||||
{ host, ... }@imports:
|
|
||||||
let
|
|
||||||
host' =
|
|
||||||
name: snippets:
|
|
||||||
let
|
|
||||||
|
|
||||||
overlay = self: super: {
|
overlay = self: super: {
|
||||||
makeModulesClosure = x: super.makeModulesClosure (x // { allowMissing = true; });
|
makeModulesClosure = x: super.makeModulesClosure (x // { allowMissing = true; });
|
||||||
|
};
|
||||||
|
|
||||||
|
common = { modulesPath, lib, ... }: {
|
||||||
|
config.nixpkgs.overlays = [ overlay ];
|
||||||
|
config.networking.hostName = lib.mkForce name;
|
||||||
|
config.home-manager = {
|
||||||
|
sharedModules = [ hmModules.default ] ;
|
||||||
};
|
};
|
||||||
|
|
||||||
common =
|
imports = [
|
||||||
{ modulesPath, lib, ... }:
|
#(modulesPath + "/installer/cd-dvd/installation-cd-minimal-new-kernel-no-zfs.nix")
|
||||||
{
|
#(modulesPath + "/installer/sd-card/sd-image-aarch64.nix")
|
||||||
config.nixpkgs.overlays = [ overlay ];
|
(modulesPath + "/installer/sd-card/sd-image-raspberrypi.nix")
|
||||||
config.networking.hostName = lib.mkForce name;
|
nixosModules.default
|
||||||
config.home-manager = {
|
inputs.home-manager.nixosModules.default
|
||||||
sharedModules = [ hmModules.default ];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
imports = [
|
system = inputs.nixpkgs.lib.nixosSystem {
|
||||||
#(modulesPath + "/installer/cd-dvd/installation-cd-minimal-new-kernel-no-zfs.nix")
|
specialArgs = { inherit inputs flake; };
|
||||||
#(modulesPath + "/installer/sd-card/sd-image-aarch64.nix")
|
modules = [ common ]
|
||||||
(modulesPath + "/installer/sd-card/sd-image-raspberrypi.nix")
|
|
||||||
nixosModules.default
|
|
||||||
inputs.home-manager.nixosModules.default
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
system = inputs.nixpkgs.lib.nixosSystem {
|
|
||||||
specialArgs = { inherit inputs flake; };
|
|
||||||
modules = [
|
|
||||||
common
|
|
||||||
]
|
|
||||||
++ snippets
|
++ snippets
|
||||||
++ builtins.attrValues nixosUsers
|
++ builtins.attrValues nixosUsers
|
||||||
++ builtins.attrValues nixosGroups;
|
++ builtins.attrValues nixosGroups
|
||||||
};
|
;
|
||||||
in
|
};
|
||||||
system.config.system.build.sdImage;
|
in system.config.system.build.sdImage;
|
||||||
|
|
||||||
in
|
in builtins.mapAttrs host' host
|
||||||
builtins.mapAttrs host' host
|
|
||||||
|
|
|
||||||
22
flake.lock
generated
22
flake.lock
generated
|
|
@ -1,26 +1,6 @@
|
||||||
{
|
{
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"nixpkgs": {
|
"root": {}
|
||||||
"locked": {
|
|
||||||
"lastModified": 1763966396,
|
|
||||||
"narHash": "sha256-6eeL1YPcY1MV3DDStIDIdy/zZCDKgHdkCmsrLJFiZf0=",
|
|
||||||
"owner": "nixos",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"rev": "5ae3b07d8d6527c42f17c876e404993199144b6a",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "nixos",
|
|
||||||
"ref": "nixos-unstable",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"root": {
|
|
||||||
"inputs": {
|
|
||||||
"nixpkgs": "nixpkgs"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"root": "root",
|
"root": "root",
|
||||||
"version": 7
|
"version": 7
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,3 @@
|
||||||
{
|
{
|
||||||
# only used for nixfmt-tree
|
|
||||||
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
|
||||||
|
|
||||||
outputs = { self, ... }@inputs: import ./lib/flake.nix inputs ./.;
|
outputs = { self, ... }@inputs: import ./lib/flake.nix inputs ./.;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
{ }
|
{}
|
||||||
|
|
|
||||||
|
|
@ -1,34 +1,21 @@
|
||||||
let
|
let
|
||||||
function =
|
function = name: value: let
|
||||||
name: value:
|
result = if builtins.isAttrs value then {...}: value else value;
|
||||||
let
|
result' = builtins.trace "result ${name}=${builtins.typeOf result}" result;
|
||||||
result = if builtins.isAttrs value then { ... }: value else value;
|
in
|
||||||
result' = builtins.trace "result ${name}=${builtins.typeOf result}" result;
|
|
||||||
in
|
|
||||||
assert builtins.isFunction result';
|
assert builtins.isFunction result';
|
||||||
result;
|
result;
|
||||||
|
|
||||||
config =
|
config = { user?{}, home-manager?{} }@set:
|
||||||
{
|
|
||||||
user ? { },
|
|
||||||
home-manager ? { },
|
|
||||||
}@set:
|
|
||||||
builtins.mapAttrs function { inherit user home-manager; };
|
builtins.mapAttrs function { inherit user home-manager; };
|
||||||
|
|
||||||
in
|
in name: value: let
|
||||||
name: value:
|
result = if builtins.isFunction value
|
||||||
let
|
then
|
||||||
result =
|
config { user = value; }
|
||||||
if builtins.isFunction value then
|
else if builtins.any (attr: builtins.hasAttr attr value) [ "user" "home-manager" ]
|
||||||
config { user = value; }
|
then
|
||||||
else if
|
config value
|
||||||
builtins.any (attr: builtins.hasAttr attr value) [
|
else
|
||||||
"user"
|
config { user = value; };
|
||||||
"home-manager"
|
in result
|
||||||
]
|
|
||||||
then
|
|
||||||
config value
|
|
||||||
else
|
|
||||||
config { user = value; };
|
|
||||||
in
|
|
||||||
result
|
|
||||||
|
|
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
name: profile: profile
|
name: profile: profile
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,81 +1,34 @@
|
||||||
let
|
let
|
||||||
scan = import ./scan.nix;
|
scan = import ./scan.nix;
|
||||||
|
|
||||||
flake' =
|
flake' = self: { imports, exports , base }@schema: { ... }@inputs: { ... }@imports: let
|
||||||
self:
|
lib = {
|
||||||
{
|
inherit scan schema inputs imports;
|
||||||
imports,
|
extend = flake schema inputs imports;
|
||||||
exports,
|
new = flake {} {} {};
|
||||||
base,
|
# TODO: override
|
||||||
}@schema:
|
};
|
||||||
{ ... }@inputs:
|
convert = attr: value: value self inputs imports;
|
||||||
{ ... }@imports:
|
|
||||||
let
|
|
||||||
lib = {
|
|
||||||
inherit
|
|
||||||
scan
|
|
||||||
schema
|
|
||||||
inputs
|
|
||||||
imports
|
|
||||||
;
|
|
||||||
extend = flake schema inputs imports;
|
|
||||||
new = flake { } { } { };
|
|
||||||
# TODO: override
|
|
||||||
};
|
|
||||||
convert = attr: value: value self inputs imports;
|
|
||||||
|
|
||||||
result = (builtins.mapAttrs convert schema.exports);
|
result = (builtins.mapAttrs convert schema.exports);
|
||||||
in
|
in result // { lib = lib // (result.lib or {}); };
|
||||||
{
|
|
||||||
formatter = builtins.mapAttrs (_: pkgs: pkgs.nixfmt-tree) inputs.nixpkgs.legacyPackages;
|
flake = { imports?{}, exports?{}, base?[] }@schema'old: { ... }@inputs'old: { ... }@imports'old: { ... }@inputs'new: base: let
|
||||||
}
|
schema = {
|
||||||
// result
|
imports = (schema'old.imports or {}) // scan { base = base + "/import"; recursive = true; };
|
||||||
// {
|
exports = (schema'old.exports or {}) // scan { base = base + "/export"; };
|
||||||
lib = lib // (result.lib or { });
|
base = [ base ] ++ (schema'old.base or []);
|
||||||
};
|
};
|
||||||
|
|
||||||
flake =
|
merge = attr: let
|
||||||
{
|
old = imports'old.${attr} or {};
|
||||||
imports ? { },
|
new = imports'new.${attr} or {};
|
||||||
exports ? { },
|
in builtins.mapAttrs (attr: _: (old.${attr} or []) ++ (new.${attr} or [])) (old//new);
|
||||||
base ? [ ],
|
|
||||||
}@schema'old:
|
|
||||||
{ ... }@inputs'old:
|
|
||||||
{ ... }@imports'old:
|
|
||||||
{ ... }@inputs'new:
|
|
||||||
base:
|
|
||||||
let
|
|
||||||
schema = {
|
|
||||||
imports =
|
|
||||||
(schema'old.imports or { })
|
|
||||||
// scan {
|
|
||||||
base = base + "/import";
|
|
||||||
recursive = true;
|
|
||||||
};
|
|
||||||
exports = (schema'old.exports or { }) // scan { base = base + "/export"; };
|
|
||||||
base = [ base ] ++ (schema'old.base or [ ]);
|
|
||||||
};
|
|
||||||
|
|
||||||
merge =
|
imports'new = builtins.mapAttrs (name: value: scan { base = base + "/${name}"; convert = name: content: [ (value name content) ]; }) schema.imports;
|
||||||
attr:
|
result = flake' result schema
|
||||||
let
|
(inputs'old // (builtins.removeAttrs inputs'new ["self"]))
|
||||||
old = imports'old.${attr} or { };
|
(builtins.mapAttrs (attr: _: merge attr) schema.imports);
|
||||||
new = imports'new.${attr} or { };
|
in result;
|
||||||
in
|
|
||||||
builtins.mapAttrs (attr: _: (old.${attr} or [ ]) ++ (new.${attr} or [ ])) (old // new);
|
|
||||||
|
|
||||||
imports'new = builtins.mapAttrs (
|
in flake {} {} {}
|
||||||
name: value:
|
|
||||||
scan {
|
|
||||||
base = base + "/${name}";
|
|
||||||
convert = name: content: [ (value name content) ];
|
|
||||||
}
|
|
||||||
) schema.imports;
|
|
||||||
result = flake' result schema (inputs'old // (builtins.removeAttrs inputs'new [ "self" ])) (
|
|
||||||
builtins.mapAttrs (attr: _: merge attr) schema.imports
|
|
||||||
);
|
|
||||||
in
|
|
||||||
result;
|
|
||||||
|
|
||||||
in
|
|
||||||
flake { } { } { }
|
|
||||||
|
|
|
||||||
1
lib/host.nix
Normal file
1
lib/host.nix
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
self:
|
||||||
53
lib/scan.nix
53
lib/scan.nix
|
|
@ -1,42 +1,23 @@
|
||||||
{
|
{ base, convert ? name: value: value, recursive ? false }:
|
||||||
base,
|
|
||||||
convert ? name: value: value,
|
|
||||||
recursive ? false,
|
|
||||||
}:
|
|
||||||
let
|
let
|
||||||
scan =
|
scan = sub: let
|
||||||
sub:
|
all = builtins.readDir (base + "/${builtins.concatStringsSep "/" sub}");
|
||||||
let
|
names = filter: builtins.filter filter (builtins.attrNames all);
|
||||||
all = builtins.readDir (base + "/${builtins.concatStringsSep "/" sub}");
|
nix = name: all.${name} == "regular" && builtins.stringLength name > 4 && builtins.substring (builtins.stringLength name - 4) 4 name == ".nix";
|
||||||
names = filter: builtins.filter filter (builtins.attrNames all);
|
dir = name: all.${name} == "directory";
|
||||||
nix =
|
files = map (name: sub ++ [ (builtins.substring 0 (builtins.stringLength name - 4) name) ]) (names nix);
|
||||||
name:
|
dirs = builtins.concatLists (map (name: scan (sub ++ [name])) (names dir));
|
||||||
all.${name} == "regular"
|
in if recursive then files ++ dirs else files;
|
||||||
&& builtins.stringLength name > 4
|
|
||||||
&& builtins.substring (builtins.stringLength name - 4) 4 name == ".nix";
|
|
||||||
dir = name: all.${name} == "directory";
|
|
||||||
files = map (name: sub ++ [ (builtins.substring 0 (builtins.stringLength name - 4) name) ]) (
|
|
||||||
names nix
|
|
||||||
);
|
|
||||||
dirs = builtins.concatLists (map (name: scan (sub ++ [ name ])) (names dir));
|
|
||||||
in
|
|
||||||
if recursive then files ++ dirs else files;
|
|
||||||
|
|
||||||
root = scan [ ];
|
root = scan [];
|
||||||
|
|
||||||
item =
|
item = relative: let
|
||||||
relative:
|
name = builtins.concatStringsSep "/" relative;
|
||||||
let
|
absolute = base + "/${name}.nix";
|
||||||
name = builtins.concatStringsSep "/" relative;
|
content = import absolute;
|
||||||
absolute = base + "/${name}.nix";
|
value = convert name content;
|
||||||
content = import absolute;
|
in { inherit name value; };
|
||||||
value = convert name content;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
inherit name value;
|
|
||||||
};
|
|
||||||
|
|
||||||
items = map item root;
|
items = map item root;
|
||||||
|
|
||||||
in
|
in if builtins.pathExists base then builtins.listToAttrs (map item root) else {}
|
||||||
if builtins.pathExists base then builtins.listToAttrs (map item root) else { }
|
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
{ }
|
{}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue