Compare commits
No commits in common. "bf39923f9ce5cd14c7fcbc40474d01f2f87fb10f" and "c651b8c4706cfc750303db12ae19e58164a6bebb" have entirely different histories.
bf39923f9c
...
c651b8c470
7 changed files with 110 additions and 199 deletions
|
@ -1,16 +1,12 @@
|
||||||
{
|
{
|
||||||
lib ? pkgs.lib,
|
|
||||||
pkgs,
|
pkgs,
|
||||||
prefix ? "trivium",
|
namespace,
|
||||||
namespace ? null,
|
|
||||||
}: let
|
}: let
|
||||||
doctrine =
|
doctrine = {
|
||||||
{
|
lib = import ./lib {inherit lib pkgs doctrine;};
|
||||||
lib = import ./lib {inherit lib pkgs doctrine;};
|
prefix = "trivium";
|
||||||
inherit namespace prefix;
|
inherit namespace;
|
||||||
}
|
};
|
||||||
// lib.optionalAttrs (pkgs != null) {
|
inherit (pkgs) lib;
|
||||||
inherit pkgs;
|
|
||||||
};
|
|
||||||
in
|
in
|
||||||
doctrine
|
doctrine
|
||||||
|
|
|
@ -13,11 +13,8 @@
|
||||||
|
|
||||||
closeLib = close {inherit lib;};
|
closeLib = close {inherit lib;};
|
||||||
closeFull = close {inherit lib pkgs doctrine;};
|
closeFull = close {inherit lib pkgs doctrine;};
|
||||||
in
|
in {
|
||||||
{
|
inherit close;
|
||||||
inherit close;
|
importAll = closeLib ./import-all.nix;
|
||||||
importAll = closeLib ./import-all.nix;
|
mkModule = closeFull ./mk-module.nix;
|
||||||
}
|
}
|
||||||
// lib.optionalAttrs (doctrine.namespace != null) {
|
|
||||||
mkModule = closeFull ./mk-module.nix;
|
|
||||||
}
|
|
||||||
|
|
|
@ -11,17 +11,14 @@
|
||||||
requires ? [],
|
requires ? [],
|
||||||
prefix ? doctrine.prefix,
|
prefix ? doctrine.prefix,
|
||||||
namespace ? doctrine.namespace,
|
namespace ? doctrine.namespace,
|
||||||
passthru ? {},
|
|
||||||
}: let
|
}: let
|
||||||
optionsSet = import options (passthru
|
optionsSet = import options {
|
||||||
// {
|
inherit config lib pkgs cfg name doctrine;
|
||||||
inherit config lib pkgs cfg name doctrine;
|
};
|
||||||
});
|
|
||||||
|
|
||||||
configSet = import configFiles.${namespace} (passthru
|
configSet = import configFiles.${namespace} {
|
||||||
// {
|
inherit config lib pkgs doctrine cfg;
|
||||||
inherit config lib pkgs doctrine cfg;
|
};
|
||||||
});
|
|
||||||
|
|
||||||
configFiles = lib.filterAttrs (k: v: v != null) {
|
configFiles = lib.filterAttrs (k: v: v != null) {
|
||||||
inherit sys hm;
|
inherit sys hm;
|
||||||
|
|
205
flake.nix
205
flake.nix
|
@ -16,24 +16,15 @@
|
||||||
"${namespace}" = builtins.removeAttrs overlayPkgs ["override"];
|
"${namespace}" = builtins.removeAttrs overlayPkgs ["override"];
|
||||||
}
|
}
|
||||||
// (overlayPkgs.override or {});
|
// (overlayPkgs.override or {});
|
||||||
|
|
||||||
doctrineNoPkgs = self.lib.mkDoctrine {
|
|
||||||
lib = nixpkgs.lib;
|
|
||||||
pkgs = null;
|
|
||||||
};
|
|
||||||
in
|
in
|
||||||
flake-utils.lib.eachDefaultSystem (system: let
|
flake-utils.lib.eachDefaultSystem (system: {
|
||||||
pkgs = import nixpkgs {inherit system;};
|
formatter = (import nixpkgs {inherit system;}).alejandra;
|
||||||
in {
|
|
||||||
formatter = pkgs.alejandra;
|
|
||||||
|
|
||||||
packages =
|
packages =
|
||||||
(import nixpkgs {
|
(import nixpkgs {
|
||||||
inherit system;
|
inherit system;
|
||||||
overlays = [(mapOverlayOverride doctrineNoPkgs.prefix (import ./pkgs))];
|
overlays = [(mapOverlayOverride "local" (import ./pkgs))];
|
||||||
}).${
|
}).local;
|
||||||
doctrineNoPkgs.prefix
|
|
||||||
};
|
|
||||||
})
|
})
|
||||||
// {
|
// {
|
||||||
templates = let
|
templates = let
|
||||||
|
@ -48,37 +39,33 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
overlays = let
|
overlays = let
|
||||||
overlay = mapOverlayOverride doctrineNoPkgs.prefix (import ./pkgs);
|
overlay = mapOverlayOverride "trivium" (import ./pkgs);
|
||||||
in {
|
in {
|
||||||
default = overlay;
|
default = overlay;
|
||||||
${doctrineNoPkgs.prefix} = overlay;
|
trivium = overlay;
|
||||||
};
|
};
|
||||||
|
|
||||||
homeManagerModules.default = ./modules;
|
homeManagerModules.default = ./modules;
|
||||||
nixosModules.default = ./modules;
|
nixosModules.default = ./modules;
|
||||||
|
|
||||||
lib = {
|
lib = {
|
||||||
mkDoctrine = import ./doctrine;
|
|
||||||
|
|
||||||
mkSystemFlake = {
|
mkSystemFlake = {
|
||||||
flakes,
|
flakes,
|
||||||
system,
|
system,
|
||||||
doctrinePrefix ? null,
|
|
||||||
formatter ? "alejandra",
|
formatter ? "alejandra",
|
||||||
paths ? {},
|
localOverlayPath ? /. + "${flakes.self}" + /pkgs,
|
||||||
|
nixpkgsConfigPath ? localOverlayPath + /config,
|
||||||
|
nixosSourcePath ? /. + "${flakes.self}" + /sys,
|
||||||
|
nixosPlatformsPath ?
|
||||||
|
if nixosSourcePath != null
|
||||||
|
then nixosSourcePath + /platform
|
||||||
|
else null,
|
||||||
|
hmSourcePath ? /. + "${flakes.self}" + /home,
|
||||||
|
hmPlatformsPath ?
|
||||||
|
if hmSourcePath != null
|
||||||
|
then hmSourcePath + /platform
|
||||||
|
else null,
|
||||||
}: let
|
}: let
|
||||||
mkDoctrine = args:
|
|
||||||
self.lib.mkDoctrine
|
|
||||||
(args
|
|
||||||
// optionalAttrs (doctrinePrefix != null) {
|
|
||||||
prefix = doctrinePrefix;
|
|
||||||
});
|
|
||||||
|
|
||||||
doctrineNoPkgs = mkDoctrine {
|
|
||||||
lib = nixpkgs.lib;
|
|
||||||
pkgs = null;
|
|
||||||
};
|
|
||||||
|
|
||||||
optionalFlake = name:
|
optionalFlake = name:
|
||||||
if flakes ? "${name}"
|
if flakes ? "${name}"
|
||||||
then flakes.${name}
|
then flakes.${name}
|
||||||
|
@ -87,7 +74,7 @@
|
||||||
requireFlake = name:
|
requireFlake = name:
|
||||||
if flakes ? "${name}"
|
if flakes ? "${name}"
|
||||||
then flakes.${name}
|
then flakes.${name}
|
||||||
else throw "Required flake input '${name}' is missing";
|
else throw "Required flake input '${name}' is required but was not provided";
|
||||||
|
|
||||||
nur = optionalFlake "nur";
|
nur = optionalFlake "nur";
|
||||||
nixpkgs = requireFlake "nixpkgs";
|
nixpkgs = requireFlake "nixpkgs";
|
||||||
|
@ -98,21 +85,13 @@
|
||||||
then requireFlake "home-manager"
|
then requireFlake "home-manager"
|
||||||
else null;
|
else null;
|
||||||
|
|
||||||
pathFromSelf = path: builtins.toPath "${flakes.self}" + "/${path}";
|
|
||||||
|
|
||||||
localOverlayPath = pathFromSelf paths.localOverlay;
|
|
||||||
nixpkgsConfigPath = pathFromSelf paths.nixpkgsConfig;
|
|
||||||
nixosSourcePath = pathFromSelf paths.nixosSource;
|
|
||||||
nixosPlatformsPath = pathFromSelf paths.nixosPlatforms;
|
|
||||||
hmSourcePath = pathFromSelf paths.hmSource;
|
|
||||||
hmPlatformsPath = pathFromSelf paths.hmPlatforms;
|
|
||||||
|
|
||||||
pkgs = importPkgs nixpkgs;
|
pkgs = importPkgs nixpkgs;
|
||||||
|
|
||||||
importPkgs = flake:
|
importPkgs = flake:
|
||||||
import flake ({
|
import flake ({
|
||||||
inherit system;
|
inherit system;
|
||||||
|
|
||||||
|
config = import ./pkgs/config nixpkgs.lib;
|
||||||
overlays = let
|
overlays = let
|
||||||
conditions = [
|
conditions = [
|
||||||
{
|
{
|
||||||
|
@ -121,7 +100,7 @@
|
||||||
}
|
}
|
||||||
# NB: Preserve the relative order
|
# NB: Preserve the relative order
|
||||||
{
|
{
|
||||||
overlay = self.overlays.default;
|
overlay = self.overlays.trivium;
|
||||||
condition = true;
|
condition = true;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
@ -132,87 +111,87 @@
|
||||||
in
|
in
|
||||||
builtins.map (cond: cond.overlay) (builtins.filter (cond: cond.condition) conditions);
|
builtins.map (cond: cond.overlay) (builtins.filter (cond: cond.condition) conditions);
|
||||||
}
|
}
|
||||||
// optionalAttrs (paths ? nixpkgsConfig) {
|
// (
|
||||||
config = import nixpkgsConfigPath {inherit (nixpkgs) lib;};
|
if nixpkgsConfigPath != null
|
||||||
});
|
then {
|
||||||
|
config = import nixpkgsConfigPath {inherit (nixpkgs) lib;};
|
||||||
|
}
|
||||||
|
else {}
|
||||||
|
));
|
||||||
|
|
||||||
inherit (pkgs) lib;
|
inherit (pkgs.trivium.lib) importAll;
|
||||||
inherit (nixpkgs.lib) optionalAttrs; # Prevents infinite recursion
|
|
||||||
inherit (doctrineNoPkgs) prefix;
|
|
||||||
inherit (doctrineNoPkgs.lib) importAll;
|
|
||||||
in
|
in
|
||||||
{
|
with pkgs.lib;
|
||||||
formatter.${system} =
|
{
|
||||||
if formatter == "alejandra"
|
formatter.${system} =
|
||||||
then pkgs.alejandra
|
if formatter == "alejandra"
|
||||||
else if formatter == "nixpkgs-fmt"
|
then pkgs.alejandra
|
||||||
then pkgs.nixpkgs-fmt
|
else if formatter == "nixpkgs-fmt"
|
||||||
else throw "Unknown formatter: '${formatter}'";
|
then pkgs.nixpkgs-fmt
|
||||||
|
else throw "Unknown formatter: '${formatter}'";
|
||||||
|
|
||||||
packages.${system} = pkgs.${prefix};
|
packages.${system} = pkgs.local;
|
||||||
|
|
||||||
overlays.default = final: prev: let
|
overlays.default = final: prev: let
|
||||||
overlay =
|
overlay =
|
||||||
if paths ? localOverlay
|
if localOverlayPath != null
|
||||||
then import localOverlayPath
|
then import localOverlayPath
|
||||||
else (final: prev: {});
|
else (final: prev: {});
|
||||||
in
|
in
|
||||||
mapOverlayOverride prefix overlay final prev
|
mapOverlayOverride "local" overlay final prev
|
||||||
// optionalAttrs (unstable != null) {
|
// optionalAttrs (unstable != null) {
|
||||||
unstable = importPkgs unstable;
|
unstable = importPkgs unstable;
|
||||||
};
|
|
||||||
}
|
|
||||||
// optionalAttrs (paths ? nixosSource) {
|
|
||||||
nixosConfigurations = let
|
|
||||||
nixosSystem = {modules}:
|
|
||||||
lib.makeOverridable nixpkgs.lib.nixosSystem {
|
|
||||||
inherit modules pkgs system;
|
|
||||||
|
|
||||||
specialArgs = {
|
|
||||||
inherit flakes;
|
|
||||||
|
|
||||||
doctrine = mkDoctrine {
|
|
||||||
inherit pkgs;
|
|
||||||
namespace = "sys";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
// optionalAttrs (nixosSourcePath != null) {
|
||||||
|
nixosConfigurations = let
|
||||||
|
nixosSystem = {modules}:
|
||||||
|
makeOverridable nixpkgs.lib.nixosSystem {
|
||||||
|
inherit modules pkgs system;
|
||||||
|
|
||||||
hostConfig = platform:
|
specialArgs = {
|
||||||
nixosSystem {
|
inherit flakes;
|
||||||
modules = [
|
|
||||||
self.nixosModules.default
|
|
||||||
nixosSourcePath
|
|
||||||
platform
|
|
||||||
];
|
|
||||||
};
|
|
||||||
in
|
|
||||||
lib.mapAttrs (_: hostConfig) (importAll {root = nixosPlatformsPath;});
|
|
||||||
}
|
|
||||||
// optionalAttrs (paths ? hmSource) {
|
|
||||||
homeConfigurations = let
|
|
||||||
home = name: platform:
|
|
||||||
home-manager.lib.homeManagerConfiguration {
|
|
||||||
inherit pkgs;
|
|
||||||
|
|
||||||
extraSpecialArgs = {
|
|
||||||
inherit flakes;
|
|
||||||
|
|
||||||
doctrine = mkDoctrine {
|
|
||||||
inherit pkgs;
|
|
||||||
namespace = "hm";
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
modules = [
|
hostConfig = platform:
|
||||||
self.homeManagerModules.default
|
nixosSystem {
|
||||||
hmSourcePath
|
modules = [
|
||||||
platform
|
self.nixosModules.default
|
||||||
];
|
nixosSourcePath
|
||||||
|
platform
|
||||||
|
];
|
||||||
|
};
|
||||||
|
in
|
||||||
|
mapAttrs (_: hostConfig) (importAll {root = nixosPlatformsPath;});
|
||||||
|
}
|
||||||
|
// optionalAttrs (hmSourcePath != null) {
|
||||||
|
homeConfigurations = let
|
||||||
|
registry = {...}: {
|
||||||
|
config.nix.registry =
|
||||||
|
mapAttrs
|
||||||
|
(_: value: {flake = value;})
|
||||||
|
flakes;
|
||||||
};
|
};
|
||||||
in
|
|
||||||
lib.mapAttrs home (importAll {root = hmPlatformsPath;});
|
home = name: platform:
|
||||||
};
|
home-manager.lib.homeManagerConfiguration {
|
||||||
|
inherit pkgs;
|
||||||
|
|
||||||
|
extraSpecialArgs = {
|
||||||
|
inherit flakes;
|
||||||
|
};
|
||||||
|
|
||||||
|
modules = [
|
||||||
|
self.homeManagerModules.default
|
||||||
|
hmSourcePath
|
||||||
|
platform
|
||||||
|
registry
|
||||||
|
];
|
||||||
|
};
|
||||||
|
in
|
||||||
|
mapAttrs home (importAll {root = hmPlatformsPath;});
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
{
|
|
||||||
config,
|
|
||||||
lib,
|
|
||||||
pkgs,
|
|
||||||
doctrine,
|
|
||||||
flakes,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
doctrine.lib.mkModule {
|
|
||||||
inherit config;
|
|
||||||
name = "nix-registry";
|
|
||||||
hm = ./hm.nix;
|
|
||||||
options = ./options.nix;
|
|
||||||
|
|
||||||
passthru = {inherit flakes;};
|
|
||||||
}
|
|
|
@ -1,23 +0,0 @@
|
||||||
{
|
|
||||||
pkgs,
|
|
||||||
lib,
|
|
||||||
cfg,
|
|
||||||
flakes,
|
|
||||||
...
|
|
||||||
}: let
|
|
||||||
registryName = name:
|
|
||||||
if name == "self"
|
|
||||||
then cfg.renameSelf
|
|
||||||
else name;
|
|
||||||
|
|
||||||
registryFilter = {
|
|
||||||
nixpkgs = true;
|
|
||||||
unstable = true;
|
|
||||||
self = cfg.renameSelf != null;
|
|
||||||
};
|
|
||||||
in {
|
|
||||||
nix.registry =
|
|
||||||
lib.mapAttrs'
|
|
||||||
(name: value: lib.nameValuePair (registryName name) {flake = value;})
|
|
||||||
(lib.filterAttrs (name: _: registryFilter.${name} or cfg.allInputs) flakes);
|
|
||||||
}
|
|
|
@ -1,19 +0,0 @@
|
||||||
{lib, ...}:
|
|
||||||
with lib.types; {
|
|
||||||
hm = {
|
|
||||||
allInputs = mkOption {
|
|
||||||
type = bool;
|
|
||||||
default = default;
|
|
||||||
description = ''
|
|
||||||
Include all flake inputs. If false, only 'nixpkgs' and 'unstable'
|
|
||||||
(if available) will be added to the flake registry by default.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
renameSelf = mkOption {
|
|
||||||
type = nullOr str;
|
|
||||||
default = "self";
|
|
||||||
description = "Registry name to use for the 'self' input";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue