-
-
Notifications
You must be signed in to change notification settings - Fork 126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide flake parts module #597
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,13 @@ in { | |
}; | ||
|
||
# generates future flake outputs: `modules.<kind>.<module-name>` | ||
config.flake.modules = lib.mapAttrs (kind: _: mapModules kind) moduleKinds; | ||
config.flake.modules = | ||
let modules = lib.mapAttrs (kind: _: mapModules kind) moduleKinds; | ||
in modules // { | ||
flake-parts = modules.flake-parts // { | ||
all-modules = { imports = flakePartsModules; _class = "flake-parts"; }; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Kinds are actually called Haven't used |
||
}; | ||
}; | ||
|
||
# comapt to current schema: `nixosModules` / `darwinModules` | ||
config.flake.nixosModules = config.flake.modules.nixos or {}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
perSystem = { | ||
{ flake-parts-lib, ... }: { | ||
options.perSystem = flake-parts-lib.mkPerSystemOption ({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This makes the options statically available for rendering. |
||
config, | ||
lib, | ||
pkgs, | ||
|
@@ -9,10 +9,25 @@ | |
in { | ||
options.writers = { | ||
writePureShellScript = lib.mkOption { | ||
type = lib.types.functionTo lib.types.anything; | ||
type = lib.types.functionTo (lib.types.functionTo lib.types.package); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've moved the documentation here, but probably the option declarations should be moved closer to the writers. Sort-of like this: options.writers = lib.mkOption { type = submodule ../writers.nix; } |
||
description = '' | ||
Create a script that runs in a `pure` environment, in the sense that: | ||
- `PATH` only contains exactly the packages passed via the `PATH` arg | ||
- `NIX_PATH` is set to the path of the current `pkgs` | ||
- `TMPDIR` is set up and cleaned up even if the script fails | ||
- out, if set, is kept as-is | ||
- all environment variables are unset, except: | ||
- the ones listed in `keepVars` below | ||
- ones listed via the `KEEP_VARS` variable | ||
- the behavior is similar to `nix-shell --pure` | ||
''; | ||
}; | ||
writePureShellScriptBin = lib.mkOption { | ||
type = lib.types.functionTo lib.types.anything; | ||
type = lib.types.functionTo (lib.types.functionTo (lib.types.functionTo lib.types.package)); | ||
description = '' | ||
Creates a script in a `bin/` directory in the output; suitable for use with `lib.makeBinPath`, etc. | ||
See {option}`writers.writePureShellScript` | ||
''; | ||
}; | ||
}; | ||
|
||
|
@@ -23,5 +38,5 @@ | |
writePureShellScriptBin | ||
; | ||
}; | ||
}; | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've assumed that this was for internal purposes, and I think it would make sense to have something like this in flake-parts for publishing modules.
It would also be nice to have an option for local modules that aren't published.