-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
225 additions
and
219 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,83 @@ | ||
{ | ||
system ? builtins.currentSystem, | ||
inputs ? import ./flake-inputs.nix, | ||
nixpkgs ? inputs.nixpkgs, | ||
dream2nix ? inputs.dream2nix, | ||
rust-overlay ? inputs.rust-overlay, | ||
sops-nix ? inputs.sops-nix, | ||
self ? { | ||
dirtyRev = "dirty"; | ||
lastModifiedDate = "19700101"; | ||
}, | ||
}: let | ||
lib = import (nixpkgs + "/lib"); | ||
lib' = import ./lib.nix {inherit lib;}; | ||
helpers = import ./helpers.nix {inherit nixpkgs dream2nix sops-nix;}; | ||
let | ||
inputs = import ./flake-inputs.nix; | ||
in | ||
{ | ||
nixpkgs ? inputs.nixpkgs, | ||
dream2nix ? inputs.dream2nix, | ||
rust-overlay ? inputs.rust-overlay, | ||
sops-nix ? inputs.sops-nix, | ||
self ? { | ||
dirtyRev = "dirty"; | ||
lastModifiedDate = "19700101"; | ||
}, | ||
system ? builtins.currentSystem, | ||
}: let | ||
lib = import (nixpkgs + "/lib"); | ||
lib' = import ./lib.nix {inherit lib;}; | ||
helpers = import ./helpers.nix {inherit nixpkgs dream2nix sops-nix;}; | ||
|
||
inherit | ||
(builtins) | ||
attrValues | ||
; | ||
inherit | ||
(builtins) | ||
attrValues | ||
; | ||
|
||
inherit | ||
(lib') | ||
mapAttrByPath | ||
; | ||
inherit | ||
(lib') | ||
mapAttrByPath | ||
; | ||
|
||
inherit | ||
(helpers) | ||
importNgiPackages | ||
importNgiProjects | ||
rawOutputs | ||
; | ||
inherit | ||
(helpers) | ||
importNgiPackages | ||
importNgiProjects | ||
rawOutputs | ||
; | ||
|
||
pkgs = import nixpkgs { | ||
inherit system; | ||
overlays = [(import rust-overlay)]; | ||
}; | ||
pkgs = import nixpkgs { | ||
inherit system; | ||
overlays = [(import rust-overlay)]; | ||
}; | ||
|
||
ngiPackages = importNgiPackages pkgs; | ||
ngiPackages = importNgiPackages pkgs; | ||
|
||
ngiProjects = importNgiProjects (pkgs // ngiPackages); | ||
ngiProjects = importNgiProjects (pkgs // ngiPackages); | ||
|
||
optionsDoc = pkgs.nixosOptionsDoc { | ||
options = | ||
(import (nixpkgs + "/nixos/lib/eval-config.nix") { | ||
inherit system; | ||
modules = | ||
[ | ||
{ | ||
networking = { | ||
domain = "invalid"; | ||
hostName = "options"; | ||
}; | ||
optionsDoc = pkgs.nixosOptionsDoc { | ||
options = | ||
(import (nixpkgs + "/nixos/lib/eval-config.nix") { | ||
inherit system; | ||
modules = | ||
[ | ||
{ | ||
networking = { | ||
domain = "invalid"; | ||
hostName = "options"; | ||
}; | ||
|
||
system.stateVersion = "23.05"; | ||
} | ||
] | ||
++ attrValues rawOutputs.nixosModules; | ||
}) | ||
.options; | ||
}; | ||
in | ||
ngiPackages | ||
// { | ||
overview = import ./overview { | ||
lib = import (nixpkgs + "/lib"); | ||
inherit pkgs self; | ||
projects = ngiProjects; | ||
options = optionsDoc.optionsNix; | ||
system.stateVersion = "23.05"; | ||
} | ||
] | ||
++ attrValues rawOutputs.nixosModules; | ||
}) | ||
.options; | ||
}; | ||
in | ||
ngiPackages | ||
// { | ||
overview = import ./overview { | ||
lib = import (nixpkgs + "/lib"); | ||
inherit pkgs self; | ||
projects = ngiProjects; | ||
options = optionsDoc.optionsNix; | ||
}; | ||
|
||
options = | ||
pkgs.runCommand "options.json" { | ||
build = optionsDoc.optionsJSON; | ||
} '' | ||
mkdir $out | ||
cp $build/share/doc/nixos/options.json $out/ | ||
''; | ||
options = | ||
pkgs.runCommand "options.json" { | ||
build = optionsDoc.optionsJSON; | ||
} '' | ||
mkdir $out | ||
cp $build/share/doc/nixos/options.json $out/ | ||
''; | ||
|
||
nixosTests = mapAttrByPath ["nixos" "tests"] {} ngiProjects; | ||
} | ||
nixosTests = mapAttrByPath ["nixos" "tests"] {} ngiProjects; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,84 +1,86 @@ | ||
{ | ||
inputs ? import ./flake-inputs.nix, | ||
nixpkgs ? inputs.nixpkgs, | ||
dream2nix ? inputs.dream2nix, | ||
sops-nix ? inputs.sops-nix, | ||
}: let | ||
lib = import (nixpkgs + "/lib"); | ||
lib' = import ./lib.nix {inherit lib;}; | ||
let | ||
inputs = import ./flake-inputs.nix; | ||
in | ||
{ | ||
nixpkgs ? inputs.nixpkgs, | ||
dream2nix ? inputs.dream2nix, | ||
sops-nix ? inputs.sops-nix, | ||
}: let | ||
lib = import (nixpkgs + "/lib"); | ||
lib' = import ./lib.nix {inherit lib;}; | ||
|
||
inherit | ||
(lib) | ||
mapAttrs | ||
recursiveUpdate | ||
attrValues | ||
filterAttrs | ||
; | ||
inherit | ||
(lib) | ||
mapAttrs | ||
recursiveUpdate | ||
attrValues | ||
filterAttrs | ||
; | ||
|
||
inherit | ||
(lib') | ||
flattenAttrsDot | ||
flattenAttrsSlash | ||
mapAttrByPath | ||
; | ||
inherit | ||
(lib') | ||
flattenAttrsDot | ||
flattenAttrsSlash | ||
mapAttrByPath | ||
; | ||
|
||
helpers = rec { | ||
# Imported from Nixpkgs | ||
nixosSystem = args: | ||
import (nixpkgs + "/nixos/lib/eval-config.nix") ({ | ||
inherit lib; | ||
system = null; | ||
} | ||
// args); | ||
helpers = rec { | ||
# Imported from Nixpkgs | ||
nixosSystem = args: | ||
import (nixpkgs + "/nixos/lib/eval-config.nix") ({ | ||
inherit lib; | ||
system = null; | ||
} | ||
// args); | ||
|
||
# NGI packages are imported from ./pkgs/by-name/default.nix. | ||
importNgiPackages = pkgs: | ||
import ./pkgs/by-name { | ||
inherit (pkgs) lib; | ||
inherit dream2nix pkgs; | ||
}; | ||
|
||
# NGI projects are imported from ./projects/default.nix. | ||
# Each project includes packages, and optionally, modules, configurations and tests. | ||
importNgiProjects = pkgs: | ||
import ./projects { | ||
inherit nixpkgs dream2nix sops-nix pkgs; | ||
}; | ||
# NGI packages are imported from ./pkgs/by-name/default.nix. | ||
importNgiPackages = pkgs: | ||
import ./pkgs/by-name { | ||
inherit (pkgs) lib; | ||
inherit dream2nix pkgs; | ||
}; | ||
|
||
# ./projects/default.nix inherits `rawNixosConfigurations` and `extendedNixosModules`. | ||
# As configurations and modules are system-agnostic, they are defined by passing `{}` to `importNgiProjects`. | ||
rawNgiProjects = importNgiProjects {}; | ||
# NGI projects are imported from ./projects/default.nix. | ||
# Each project includes packages, and optionally, modules, configurations and tests. | ||
importNgiProjects = pkgs: | ||
import ./projects { | ||
inherit nixpkgs dream2nix sops-nix pkgs; | ||
}; | ||
|
||
rawNixosConfigurations = flattenAttrsSlash (mapAttrs (_: v: mapAttrs (_: v: v.path) v) ( | ||
mapAttrByPath ["nixos" "configurations"] {} rawNgiProjects | ||
)); | ||
# ./projects/default.nix inherits `rawNixosConfigurations` and `extendedNixosModules`. | ||
# As configurations and modules are system-agnostic, they are defined by passing `{}` to `importNgiProjects`. | ||
rawNgiProjects = importNgiProjects {}; | ||
|
||
rawNixosModules = flattenAttrsDot (lib.foldl recursiveUpdate {} (attrValues ( | ||
mapAttrByPath ["nixos" "modules"] {} rawNgiProjects | ||
))); | ||
rawNixosConfigurations = flattenAttrsSlash (mapAttrs (_: v: mapAttrs (_: v: v.path) v) ( | ||
mapAttrByPath ["nixos" "configurations"] {} rawNgiProjects | ||
)); | ||
|
||
rawOutputs = { | ||
nixosModules = | ||
{ | ||
unbootable = ./modules/unbootable.nix; | ||
# The default module adds the default overlay on top of Nixpkgs. | ||
# This is so that `ngipkgs` can be used alongside `nixpkgs` in a configuration. | ||
default.nixpkgs.overlays = [rawOutputs.overlays.default]; | ||
} | ||
// (filterAttrs (_: v: v != null) rawNixosModules); | ||
overlays.default = final: prev: importNgiPackages prev; | ||
}; | ||
rawNixosModules = flattenAttrsDot (lib.foldl recursiveUpdate {} (attrValues ( | ||
mapAttrByPath ["nixos" "modules"] {} rawNgiProjects | ||
))); | ||
|
||
extendedNixosModules = | ||
rawOutputs.nixosModules | ||
// { | ||
sops-nix = import (sops-nix + "/modules/sops"); | ||
rawOutputs = { | ||
nixosModules = | ||
{ | ||
unbootable = ./modules/unbootable.nix; | ||
# The default module adds the default overlay on top of Nixpkgs. | ||
# This is so that `ngipkgs` can be used alongside `nixpkgs` in a configuration. | ||
default.nixpkgs.overlays = [rawOutputs.overlays.default]; | ||
} | ||
// (filterAttrs (_: v: v != null) rawNixosModules); | ||
overlays.default = final: prev: importNgiPackages prev; | ||
}; | ||
|
||
extendedNixosConfigurations = | ||
mapAttrs | ||
(_: config: nixosSystem {modules = [config ./dummy.nix] ++ attrValues extendedNixosModules;}) | ||
rawNixosConfigurations; | ||
}; | ||
in | ||
helpers | ||
extendedNixosModules = | ||
rawOutputs.nixosModules | ||
// { | ||
sops-nix = import (sops-nix + "/modules/sops"); | ||
}; | ||
|
||
extendedNixosConfigurations = | ||
mapAttrs | ||
(_: config: nixosSystem {modules = [config ./dummy.nix] ++ attrValues extendedNixosModules;}) | ||
rawNixosConfigurations; | ||
}; | ||
in | ||
helpers |
Oops, something went wrong.