Skip to content

Commit

Permalink
fix: devshellProfiles.rust requiredInputs check
Browse files Browse the repository at this point in the history
  • Loading branch information
GTrunSec committed Oct 12, 2023
1 parent a48aff6 commit f20247c
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 36 deletions.
25 changes: 10 additions & 15 deletions lib/errors/requiredInputs.nix
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
{
lib,
inputs,
super,
}:
{ lib, super }:
inputs': unit: listNames:
let
fondInputs =
if
(lib.length (
lib.filter (pair: pair == true) (map (v: lib.hasAttr v inputs) listNames)
lib.filter (pair: pair == true) (map (v: lib.hasAttr v inputs') listNames)
)) > 0
then
true
else
false
;
msg =
(lib.concatMapStringsSep "\n "
(lib.concatMapStringsSep "\n "
(
{ name, url }:
''
# please get the input from `${name}.url = "${url}"`
${name} = inputs.${name};
${name} = inputs.${name};
''
)
(super.inputsSource listNames)
Expand All @@ -38,14 +34,13 @@ assert lib.assertMsg fondInputs ''
please, add the these inputs into
omnibus.${unit}.addLoadExtender {
load.inputs = {
${msg}
# you can also see the full inputs list at
# https://github.com/GTrunSec/omnibus/blob/main/local/lock/flake.nix#L1
load.inputs =
inputs = {
${msg}
# you can also see the full inputs list at
# https://github.com/GTrunSec/omnibus/blob/main/local/lock/flake.nix#L1
};
};
};
}
'';
assert lib.assertMsg noSysNixpkgs ''
please, add the following inputs into
Expand Down
6 changes: 4 additions & 2 deletions tests/devshell/expr.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ let
POP.lib.extendPop flops.lib.flake.pops.inputsExtender (
self: super: {
inputs = {
nixpkgs = loadInputs.outputs.nixpkgs.legacyPackages;
devshell = loadInputs.outputs.devshell.legacyPackages;
nixpkgs = loadInputs.outputs.nixpkgs.legacyPackages;
};
}
)
Expand All @@ -25,7 +25,9 @@ let
devshellProfiles =
(omnibus.pops.devshell.loadProfiles.addLoadExtender {
load.inputs = {
inherit (inputs) fenix nixpkgs;
inputs = {
inherit (inputs) fenix nixpkgs;
};
};
}).layouts.default;

Expand Down
34 changes: 17 additions & 17 deletions units/devshell/modules/language/rust.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@
type = types.nullOr types.package;
default = null;
};
overlays = mkOption {
type = types.lazyAttrsOf (
types.uniq (
types.functionTo (types.functionTo (types.lazyAttrsOf types.unspecified))
)
);
apply = lib.mapAttrs (
_k: f: final: prev:
f final prev
);
default = { };
example = lib.literalExpression or lib.literalExample ''
{
default = final: prev: {};
}
'';
};
# overlays = mkOption {
# type = types.lazyAttrsOf (
# types.uniq (
# types.functionTo (types.functionTo (types.lazyAttrsOf types.unspecified))
# )
# );
# apply = lib.mapAttrs (
# _k: f: final: prev:
# f final prev
# );
# default = { };
# example = lib.literalExpression or lib.literalExample ''
# {
# default = final: prev: {};
# }
# '';
# };
};
}
18 changes: 16 additions & 2 deletions units/devshell/profiles/rust.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
{
omnibus,
inputs,
config,
extraModulesPath,
}:
let
pkgs' = nixpkgs.appendOverlays [ config.language.rust.overlays.default ];
inherit
(omnibus.lib.errors.requiredInputs inputs "devshellProfiles" [
"nixpkgs"
"fenix"
])
fenix
nixpkgs
;

pkgs' = nixpkgs.appendOverlays [ fenix.overlay ];
cfg = config.language.rust;
in
{
Expand All @@ -9,7 +24,6 @@ in
];

language.rust = {
overlays = fenix.overlays;
rustSrc = pkgs'.fenix.complete.rust-src;
packageSet = pkgs'.fenix.default;
enableDefaultToolchain = true;
Expand Down

0 comments on commit f20247c

Please sign in to comment.