Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions modules/misc/news/2025/10/2025-10-25_14-37-46.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
time = "2025-10-25T21:37:46+00:00";
condition = true;
message = ''
A new module is available: `programs.go-freeze`

`go-freeze` is a CLI tool that to generate mages of code and terminal
output.

This module allows for defining named configuration files via
`settings.<name>` attributes, ex.

```nix
{
programs.go-freeze = {
enable = true;

settings.user = {
theme = "gruvbox-dark";
};
};
}
```

... which may be activated at runtime by name;

```bash
go-freeze -c user -l bash <<<'echo "hello world"';
```
'';
}
98 changes: 98 additions & 0 deletions modules/programs/go-freeze.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
{
config,
lib,
# pkgs,
...
}:
let
# TODO: remove following and uncomment `pkgs` above after;
# - NixOS/nixpkgs# is accepted
# - nix-community/home-manager is updated
pkgs = import /home/s0ands0/git/hub/NixOS/nixpkgs/wt/add-go-freeze { };

inherit (lib)
mkEnableOption
mkIf
mkOption
mkPackageOption
literalExpression
;

inherit (lib.types) submodule;

inherit (pkgs.formats) json;

jsonFormat = json { };

cfg = config.programs.go-freeze;
in
{
options.programs.go-freeze = {
enable = mkEnableOption "Enable pianobar";

package = mkPackageOption pkgs "go-freeze" {
nullable = true;
};

settings = mkOption {
default = { };

description = ''
Attribute set of named configuration files to write.
'';

example = literalExpression ''
{
programs.go-freeze = {
enable = true;

settings.user = {
background = "#171717";
margin = [0 0 0 0];
padding = [20 40 20 20];
window = false;
width = 0;
height = 0;
config = "default";
theme = "gruvbox-dark";
border = { radius = 0; width = 0; color = "#515151"; };
shadow = { blur = 0; x = 0; y = 0; };
font = {
family = "Liberation Mono";
file = "''${pkgs.liberation_ttf_v2}/share/fonts/truetype/LiberationMono-Regular.ttf";
size = 14;
ligatures = false;
};
line_height = 1.2;
line_numbers = false;
};
};
}
'';

type = lib.types.attrsOf (submodule {
freeformType = jsonFormat.type;
});

};
};

config = mkIf cfg.enable {
xdg.configFile = lib.mkIf (cfg.settings != { }) (
lib.listToAttrs (
lib.mapAttrsToList (name: value: {
name = "go-freeze/${name}.json";
value.source = jsonFormat.generate "go-freeze-config-${name}" value;
}) cfg.settings
)
);

home.packages = mkIf (cfg.package != null) [
cfg.package
];
};

meta.maintainers = [
lib.maintainers.S0AndS0
];
}
4 changes: 4 additions & 0 deletions tests/modules/programs/go-freeze/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
go-freeze-minimally-required-configs = ./minimally-required-configs.nix;
go-freeze-settings-user = ./settings-user.nix;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
programs.go-freeze.enable = true;
}
91 changes: 91 additions & 0 deletions tests/modules/programs/go-freeze/settings-user.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
{ pkgs, ... }:
{
programs.go-freeze = {
enable = true;

settings.user = {
background = "#171717";
margin = [
0
0
0
0
];
padding = [
20
40
20
20
];
window = false;
width = 0;
height = 0;
config = "default";
theme = "gruvbox-dark";
border = {
radius = 0;
width = 0;
color = "#515151";
};
shadow = {
blur = 0;
x = 0;
y = 0;
};
font = {
family = "Liberation Mono";
file = "${pkgs.liberation_ttf_v2}/share/fonts/truetype/LiberationMono-Regular.ttf";
size = 14;
ligatures = false;
};
line_height = 1.2;
line_numbers = false;
};
};

nmt.script = ''
assertFileExists home-files/.config/go-freeze/user.json

assertFileContent home-files/.config/go-freeze/user.json \
${builtins.toFile "expected.config_go-freeze_user.json" ''
{
"background": "#171717",
"border": {
"color": "#515151",
"radius": 0,
"width": 0
},
"config": "default",
"font": {
"family": "Liberation Mono",
"file": "${pkgs.liberation_ttf_v2}/share/fonts/truetype/LiberationMono-Regular.ttf",
"ligatures": false,
"size": 14
},
"height": 0,
"line_height": 1.2,
"line_numbers": false,
"margin": [
0,
0,
0,
0
],
"padding": [
20,
40,
20,
20
],
"shadow": {
"blur": 0,
"x": 0,
"y": 0
},
"theme": "gruvbox-dark",
"width": 0,
"window": false
}
''}
'';
}