mirror of
https://github.com/nix-community/home-manager.git
synced 2025-12-06 17:11:03 +01:00
nix-init: add module (#6864)
Co-authored-by: uncenter <47499684+uncenter@users.noreply.github.com>
This commit is contained in:
parent
08b85bd000
commit
be4e5ec62c
7 changed files with 115 additions and 0 deletions
1
.github/labeler.yml
vendored
1
.github/labeler.yml
vendored
|
|
@ -292,6 +292,7 @@
|
|||
- modules/programs/pylint.nix
|
||||
- modules/programs/mise.nix
|
||||
- modules/programs/nix-index.nix
|
||||
- modules/programs/nix-init.nix
|
||||
- modules/programs/nh.nix
|
||||
- modules/programs/bacon.nix
|
||||
- modules/programs/sqls.nix
|
||||
|
|
|
|||
9
modules/misc/news/2025-04-20_18-44-29.nix
Normal file
9
modules/misc/news/2025-04-20_18-44-29.nix
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
time = "2025-04-21T01:44:29+00:00";
|
||||
condition = true;
|
||||
message = ''
|
||||
A new module is available: 'programs.nix-init'.
|
||||
|
||||
nix-init generate Nix packages from URLs.
|
||||
'';
|
||||
}
|
||||
|
|
@ -198,6 +198,7 @@ let
|
|||
./programs/nh.nix
|
||||
./programs/nheko.nix
|
||||
./programs/nix-index.nix
|
||||
./programs/nix-init.nix
|
||||
./programs/nix-your-shell.nix
|
||||
./programs/nnn.nix
|
||||
./programs/noti.nix
|
||||
|
|
|
|||
60
modules/programs/nix-init.nix
Normal file
60
modules/programs/nix-init.nix
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
{
|
||||
lib,
|
||||
pkgs,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
let
|
||||
tomlFormat = pkgs.formats.toml { };
|
||||
cfg = config.programs.nix-init;
|
||||
in
|
||||
{
|
||||
meta.maintainers = [ lib.maintainers.awwpotato ];
|
||||
|
||||
options.programs.nix-init = {
|
||||
enable = lib.mkEnableOption "nix-init";
|
||||
package = lib.mkPackageOption pkgs "nix-init" { nullable = true; };
|
||||
settings = lib.mkOption {
|
||||
type = tomlFormat.type;
|
||||
default = { };
|
||||
example = lib.literalExpression ''
|
||||
{
|
||||
maintainers = [
|
||||
"figsoda"
|
||||
];
|
||||
nixpkgs = "<nixpkgs>";
|
||||
commit = true;
|
||||
access-tokens = {
|
||||
github.com = "ghp_blahblahblah...";
|
||||
gitlab.com = {
|
||||
command = [
|
||||
"secret-tool"
|
||||
"or"
|
||||
"whatever"
|
||||
"you"
|
||||
"use"
|
||||
];
|
||||
};
|
||||
gitlab.gnome.org = {
|
||||
file = "/path/to/api/token";
|
||||
};
|
||||
};
|
||||
}
|
||||
'';
|
||||
description = ''
|
||||
Configuration written to
|
||||
{file}`$XDG_CONFIG_HOME/nix-init/config.toml`.
|
||||
See <https://github.com/nix-community/nix-init#configuration> for the full list
|
||||
of options.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
|
||||
|
||||
xdg.configFile."nix-init/config.toml" = lib.mkIf (cfg.settings != { }) {
|
||||
source = tomlFormat.generate "config.toml" cfg.settings;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -418,6 +418,7 @@ import nmtSrc {
|
|||
./modules/programs/newsboat
|
||||
./modules/programs/nheko
|
||||
./modules/programs/nix-index
|
||||
./modules/programs/nix-init
|
||||
./modules/programs/nix-your-shell
|
||||
./modules/programs/nnn
|
||||
./modules/programs/nushell
|
||||
|
|
|
|||
40
tests/modules/programs/nix-init/basic-config.nix
Normal file
40
tests/modules/programs/nix-init/basic-config.nix
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
{ pkgs, ... }:
|
||||
{
|
||||
programs.nix-init = {
|
||||
enable = true;
|
||||
settings = {
|
||||
maintainers = [ "figsoda" ];
|
||||
nixpkgs = "<nixpkgs>";
|
||||
commit = true;
|
||||
access-tokens = {
|
||||
"github.com" = "ghp_blahblahblah...";
|
||||
"gitlab.com".command = [
|
||||
"secret-tool"
|
||||
"or"
|
||||
"whatever"
|
||||
"you"
|
||||
"use"
|
||||
];
|
||||
"gitlab.gnome.org".file = "/path/to/api/token";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists home-files/.config/nix-init/config.toml
|
||||
assertFileContent home-files/.config/nix-init/config.toml \
|
||||
${pkgs.writeText "settings-expected" ''
|
||||
commit = true
|
||||
maintainers = ["figsoda"]
|
||||
nixpkgs = "<nixpkgs>"
|
||||
[access-tokens]
|
||||
"github.com" = "ghp_blahblahblah..."
|
||||
|
||||
[access-tokens."gitlab.com"]
|
||||
command = ["secret-tool", "or", "whatever", "you", "use"]
|
||||
|
||||
[access-tokens."gitlab.gnome.org"]
|
||||
file = "/path/to/api/token"
|
||||
''}
|
||||
'';
|
||||
}
|
||||
3
tests/modules/programs/nix-init/default.nix
Normal file
3
tests/modules/programs/nix-init/default.nix
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
nix-init-basic-config = ./basic-config.nix;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue