fix nixpkgs.channels system
This commit is contained in:
parent
7ad231ae5c
commit
52044bd998
7 changed files with 92 additions and 56 deletions
|
|
@ -15,14 +15,19 @@
|
||||||
mix,
|
mix,
|
||||||
deploy-rs,
|
deploy-rs,
|
||||||
...
|
...
|
||||||
} @ inputs:
|
} @ args:
|
||||||
mix.newMixture inputs (mixture: {
|
mix.newMixture args (mixture: {
|
||||||
includes.public = [
|
includes.public = [
|
||||||
./nexus
|
./nexus
|
||||||
];
|
];
|
||||||
|
|
||||||
version = "0.1.0";
|
version = "0.1.0";
|
||||||
|
|
||||||
|
nixosModules = rec {
|
||||||
|
default = cerulean;
|
||||||
|
cerulean = ./nixos-module;
|
||||||
|
};
|
||||||
|
|
||||||
overlays = [
|
overlays = [
|
||||||
# build deploy-rs as a package not from the flake input,
|
# build deploy-rs as a package not from the flake input,
|
||||||
# hence we can rely on a nixpkg binary cache.
|
# hence we can rely on a nixpkg binary cache.
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,8 @@
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
{mix, ...} @ inputs:
|
{mix, ...} @ args:
|
||||||
mix.newMixture inputs (mixture: {
|
mix.newMixture args (mixture: {
|
||||||
includes.public = [
|
includes.public = [
|
||||||
./nodes.nix
|
./nodes.nix
|
||||||
./nexus.nix
|
./nexus.nix
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
{
|
{
|
||||||
|
self,
|
||||||
this,
|
this,
|
||||||
nt,
|
nt,
|
||||||
lib,
|
lib,
|
||||||
|
|
@ -184,15 +185,18 @@ in {
|
||||||
nodeName: node: let
|
nodeName: node: let
|
||||||
nixosDecl = lib.nixosSystem {
|
nixosDecl = lib.nixosSystem {
|
||||||
system = node.system;
|
system = node.system;
|
||||||
specialArgs =
|
specialArgs = let
|
||||||
nexus.specialArgs
|
specialArgs =
|
||||||
// node.specialArgs
|
nexus.specialArgs
|
||||||
// {
|
// node.specialArgs
|
||||||
inherit root;
|
// {
|
||||||
inherit (node) system;
|
inherit root specialArgs;
|
||||||
};
|
inherit (node) system;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
specialArgs;
|
||||||
modules =
|
modules =
|
||||||
[../nixos-module (findImport (root + "/hosts/${nodeName}"))]
|
[self.nixosModules.default (findImport (root + "/hosts/${nodeName}"))]
|
||||||
++ (getGroupModules root nodeName node)
|
++ (getGroupModules root nodeName node)
|
||||||
++ node.extraModules
|
++ node.extraModules
|
||||||
++ nexus.extraModules;
|
++ nexus.extraModules;
|
||||||
|
|
|
||||||
|
|
@ -11,9 +11,17 @@
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
{deploy-rs, ...}: {
|
{
|
||||||
|
root,
|
||||||
|
deploy-rs,
|
||||||
|
...
|
||||||
|
} @ args: {
|
||||||
imports = [
|
imports = [
|
||||||
./nixpkgs.nix
|
# user configuration
|
||||||
|
(import (root + "/nixpkgs.nix"))
|
||||||
|
# options declarations
|
||||||
|
(import ./nixpkgs.nix (args // {contextName = "hosts";}))
|
||||||
|
|
||||||
./home-manager.nix
|
./home-manager.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,15 +15,27 @@
|
||||||
root,
|
root,
|
||||||
config,
|
config,
|
||||||
lib,
|
lib,
|
||||||
|
specialArgs,
|
||||||
...
|
...
|
||||||
} @ args: {
|
} @ args: let
|
||||||
|
inherit
|
||||||
|
(builtins)
|
||||||
|
attrNames
|
||||||
|
filter
|
||||||
|
pathExists
|
||||||
|
;
|
||||||
|
in {
|
||||||
home-manager = {
|
home-manager = {
|
||||||
users =
|
users =
|
||||||
config.users.users
|
config.users.users
|
||||||
|> builtins.attrNames
|
|> attrNames
|
||||||
|> builtins.filter (x: builtins.pathExists (root + "/homes/${x}"))
|
|> filter (x: pathExists (root + "/homes/${x}"))
|
||||||
|> (x: lib.genAttrs x (y: import (root + "/homes/${y}")));
|
|> (x: lib.genAttrs x (y: import (root + "/homes/${y}")));
|
||||||
|
|
||||||
extraSpecialArgs = args;
|
extraSpecialArgs = specialArgs;
|
||||||
|
sharedModules = [
|
||||||
|
(import (root + "/nixpkgs.nix"))
|
||||||
|
(import ./nixpkgs.nix (args // {contextName = "homes";}))
|
||||||
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,9 +12,10 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
{
|
{
|
||||||
nt,
|
|
||||||
lib,
|
lib,
|
||||||
|
system,
|
||||||
config,
|
config,
|
||||||
|
contextName,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit
|
inherit
|
||||||
|
|
@ -22,62 +23,68 @@
|
||||||
mapAttrs
|
mapAttrs
|
||||||
;
|
;
|
||||||
|
|
||||||
inherit
|
cfg = config.nixpkgs.channels;
|
||||||
(nt)
|
|
||||||
flip
|
|
||||||
;
|
|
||||||
|
|
||||||
cfg = config.pkgsrc;
|
|
||||||
in {
|
in {
|
||||||
options.pkgsrc = lib.mkOption {
|
options.nixpkgs.channels = lib.mkOption {
|
||||||
type = lib.types.attrsOf lib.types.attrs;
|
type = lib.types.attrsOf (lib.types.attrs);
|
||||||
default = {};
|
default = {};
|
||||||
description = "Declare and import custom package repositories.";
|
description = "Declare package repositories per module context (nixos, home-manager, etc)";
|
||||||
example = {
|
example = {
|
||||||
"pkgs" = {
|
"homes" = {
|
||||||
source = "inputs.nixpkgs";
|
"pkgs" = {
|
||||||
system = "x86-64-linux";
|
source = "inputs.nixpkgs";
|
||||||
config = {
|
system = "x86-64-linux";
|
||||||
allowUnfree = true;
|
config = {
|
||||||
allowBroken = false;
|
allowUnfree = true;
|
||||||
|
allowBroken = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
"upkgs" = {
|
||||||
|
source = "inputs.nixpkgs-unstable";
|
||||||
|
system = "x86-64-linux";
|
||||||
|
config = {
|
||||||
|
allowUnfree = true;
|
||||||
|
allowBroken = false;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# or abort ''
|
||||||
|
# `nixpkgs.channels.${contextName}` does not exist, but neither does `nixpkgs.channels.default`!
|
||||||
|
# A channel configuration must be declared for module context "${contextName}".
|
||||||
|
# ''
|
||||||
|
|
||||||
config = let
|
config = let
|
||||||
# TODO: use lib.types.submodule to restrict what options
|
# TODO: use lib.types.submodule to restrict what options
|
||||||
# TODO: can be given to pkgsrc
|
# TODO: can be given to `nixpkgs.channels.${moduleName}.${name}`
|
||||||
|
decl =
|
||||||
|
cfg.${contextName} or cfg.default;
|
||||||
|
|
||||||
repos =
|
repos =
|
||||||
cfg
|
decl
|
||||||
|> mapAttrs (
|
|> mapAttrs (
|
||||||
name: args:
|
name: args:
|
||||||
assert args ? source
|
assert args ? source
|
||||||
|| abort ''
|
|| abort ''
|
||||||
${./.}
|
${toString ./.}
|
||||||
`pkgsrc.${name} missing required attribute "source"`
|
`nixpkgs.channels.${contextName}.${name} missing required attribute "source"`
|
||||||
'';
|
'';
|
||||||
args
|
((removeAttrs args ["source"])
|
||||||
|> flip removeAttrs ["source"]
|
// {inherit system;})
|
||||||
|> import args.source
|
|> import args.source
|
||||||
|
|> lib.mkOverride 200
|
||||||
);
|
);
|
||||||
in {
|
in {
|
||||||
# NOTE: _module.args is a special option that allows us to
|
# NOTE: _module.args is a special option that allows us to
|
||||||
# NOTE: set extend specialArgs from inside the modules.
|
# NOTE: set extend specialArgs from inside the modules.
|
||||||
# "pkgs" is unique since the nix module system already handles it
|
# "pkgs" is unique since the nix module system already handles it
|
||||||
_module.args =
|
_module.args = removeAttrs repos ["pkgs"];
|
||||||
removeAttrs repos ["pkgs"];
|
|
||||||
|
|
||||||
# nixpkgs =
|
nixpkgs =
|
||||||
# lib.mkIf (cfg ? pkgs)
|
if contextName == "hosts"
|
||||||
# (let
|
then {flake.source = lib.mkIf (decl ? pkgs) (lib.mkOverride 200 decl.pkgs.source);}
|
||||||
# pkgs = cfg.pkgs;
|
else {};
|
||||||
# in
|
|
||||||
# lib.mkForce (
|
|
||||||
# (removeAttrs pkgs ["source"])
|
|
||||||
# // {
|
|
||||||
# flake.source = pkgs.source;
|
|
||||||
# }
|
|
||||||
# ));
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
6
flake.lock
generated
6
flake.lock
generated
|
|
@ -175,11 +175,11 @@
|
||||||
"systems": "systems_2"
|
"systems": "systems_2"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1770950436,
|
"lastModified": 1770975056,
|
||||||
"narHash": "sha256-+h5jrsIJBea5P+rAk4OqUpScqnHYQTvCRUhgGv/MX34=",
|
"narHash": "sha256-ZXTz/P3zUbbM6lNXzt91u8EwfNqhXpYMu8+wvFZqQHE=",
|
||||||
"owner": "cry128",
|
"owner": "cry128",
|
||||||
"repo": "nt",
|
"repo": "nt",
|
||||||
"rev": "8725f5079f8f27b3faafeff90e5fc075d55e7d0a",
|
"rev": "f42dcdd49a7921a7f433512e83d5f93696632412",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue