flake: rework the nixpkgs init code
This commit is contained in:
parent
19bb39a8b4
commit
dfcb303eef
70
flake.nix
70
flake.nix
|
@ -22,6 +22,10 @@
|
||||||
(import "${lix-module}/overlay.nix" { inherit lix; })
|
(import "${lix-module}/overlay.nix" { inherit lix; })
|
||||||
];
|
];
|
||||||
forAllSystems = nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed;
|
forAllSystems = nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed;
|
||||||
|
libVersionInfoOverlay = import "${nixpkgs}/lib/flake-version-info.nix" nixpkgs;
|
||||||
|
# this is taken from upstream. if upstream changes, the code here needs to be updated to match
|
||||||
|
addLibVersionInfo = lib: lib.extend libVersionInfoOverlay;
|
||||||
|
lib-base = addLibVersionInfo (import "${nixpkgs}/lib");
|
||||||
in {
|
in {
|
||||||
# we don't just use nix.registry.whatever.flake = self
|
# we don't just use nix.registry.whatever.flake = self
|
||||||
# the reason for this is to be able to handle a flake.lock containing an entry for this
|
# the reason for this is to be able to handle a flake.lock containing an entry for this
|
||||||
|
@ -42,8 +46,41 @@
|
||||||
# the nix path entry for self
|
# the nix path entry for self
|
||||||
meta.path-entry = "dragnpkgs-unstable=flake:dragnpkgs-unstable";
|
meta.path-entry = "dragnpkgs-unstable=flake:dragnpkgs-unstable";
|
||||||
|
|
||||||
lib = nixpkgs.lib.extend (final: prev: {
|
lib = (lib-base.extend (import ./lib/overlay.nix)).extend (final: prev: {
|
||||||
licenses = prev.licenses // { fyptl = import ./lib/licenses/fyptl.nix; };
|
# initializes regular upstream nixpkgs with the given arguments
|
||||||
|
nixpkgs-custom = { system, ... } @ args: (
|
||||||
|
(import "${nixpkgs}" args).extend (final: prev: {
|
||||||
|
lib = addLibVersionInfo prev.lib;
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
# initializes dragnpkgs with its overlays and default config using the given arguments
|
||||||
|
dragnpkgs-custom = { system, ... } @ args: let
|
||||||
|
unsafeConf = if builtins.hasAttr "extraBuiltins" builtins then (
|
||||||
|
let conf = builtins.extraBuiltins; in
|
||||||
|
if builtins.isAttrs conf then conf else {}
|
||||||
|
) else {};
|
||||||
|
possiblyCommitCrimes =
|
||||||
|
if
|
||||||
|
builtins.hasAttr "dragnpkgs" unsafeConf &&
|
||||||
|
builtins.isAttrs unsafeConf.dragnpkgs &&
|
||||||
|
builtins.hasAttr "possiblyCommitCrimes" unsafeConf.dragnpkgs &&
|
||||||
|
builtins.isBool unsafeConf.dragnpkgs.possiblyCommitCrimes
|
||||||
|
then
|
||||||
|
unsafeConf.dragnpkgs.possiblyCommitCrimes
|
||||||
|
else
|
||||||
|
false;
|
||||||
|
in
|
||||||
|
final.nixpkgs-custom (args // {
|
||||||
|
overlays = overlays ++ (args.overlays or []);
|
||||||
|
config = (args.config or {}) // {
|
||||||
|
allowlistedLicenses = (final.optionals
|
||||||
|
possiblyCommitCrimes
|
||||||
|
[ final.licenses.fyptl ]) ++ (args.config.allowlistedLicenses or []);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
nixos = import "${nixpkgs}/nixos/lib" { lib = final; };
|
||||||
|
|
||||||
nixosSystem = args:
|
nixosSystem = args:
|
||||||
import "${nixpkgs}/nixos/lib/eval-config.nix" (
|
import "${nixpkgs}/nixos/lib/eval-config.nix" (
|
||||||
|
@ -192,36 +229,9 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
legacyPackages = forAllSystems (system:
|
legacyPackages = forAllSystems (system:
|
||||||
let
|
self.lib.dragnpkgs-custom { inherit system; }
|
||||||
unsafeConf = if builtins.hasAttr "extraBuiltins" builtins then (
|
|
||||||
let conf = builtins.extraBuiltins; in
|
|
||||||
if builtins.isAttrs conf then conf else {}
|
|
||||||
) else {};
|
|
||||||
possiblyCommitCrimes =
|
|
||||||
if
|
|
||||||
builtins.hasAttr "dragnpkgs" unsafeConf &&
|
|
||||||
builtins.isAttrs unsafeConf.dragnpkgs &&
|
|
||||||
builtins.hasAttr "possiblyCommitCrimes" unsafeConf.dragnpkgs &&
|
|
||||||
builtins.isBool unsafeConf.dragnpkgs.possiblyCommitCrimes
|
|
||||||
then
|
|
||||||
unsafeConf.dragnpkgs.possiblyCommitCrimes
|
|
||||||
else
|
|
||||||
false;
|
|
||||||
in
|
|
||||||
nixpkgs.legacyPackages.${system}.appendOverlays (overlays ++
|
|
||||||
[(final: prev: {
|
|
||||||
stdenv = prev.stdenv.override {
|
|
||||||
config = prev.config // {
|
|
||||||
allowlistedLicenses = final.lib.optionals
|
|
||||||
possiblyCommitCrimes
|
|
||||||
[ final.lib.licenses.fyptl ];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
})])
|
|
||||||
);
|
);
|
||||||
|
|
||||||
nixosModules = nixpkgs.nixosModules;
|
|
||||||
|
|
||||||
templates = {
|
templates = {
|
||||||
default = {
|
default = {
|
||||||
path = ./templates/default;
|
path = ./templates/default;
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
final: prev: {
|
||||||
|
licenses = prev.licenses // { fyptl = import ./licenses/fyptl.nix; };
|
||||||
|
}
|
|
@ -1,7 +1,5 @@
|
||||||
final: prev: {
|
final: prev: {
|
||||||
lib = prev.lib.extend (lfinal: lprev: {
|
lib = prev.lib.extend (import ./lib/overlay.nix);
|
||||||
licenses = lprev.licenses // { fyptl = import ./lib/licenses/fyptl.nix; };
|
|
||||||
});
|
|
||||||
|
|
||||||
fetchFromSteam = prev.callPackage ./lib/fetchsteam {};
|
fetchFromSteam = prev.callPackage ./lib/fetchsteam {};
|
||||||
fetchb4 = prev.callPackage ./lib/fetchb4 {};
|
fetchb4 = prev.callPackage ./lib/fetchb4 {};
|
||||||
|
|
Loading…
Reference in New Issue