1
0
Fork 0
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:
awwpotato 2025-04-21 10:25:56 -07:00 committed by GitHub
parent 08b85bd000
commit be4e5ec62c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 115 additions and 0 deletions

1
.github/labeler.yml vendored
View file

@ -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

View 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.
'';
}

View file

@ -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

View 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;
};
};
}

View file

@ -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

View 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"
''}
'';
}

View file

@ -0,0 +1,3 @@
{
nix-init-basic-config = ./basic-config.nix;
}