format: format nixos installable

This commit is contained in:
Ophestra 2025-07-13 23:55:04 +09:00
commit 7a6404165e
Signed by: cat
SSH Key Fingerprint: SHA256:gQ67O0enBZ7UdZypgtspB2FDM1g3GVw8nX0XSdcFw8Q
4 changed files with 61 additions and 0 deletions

25
.gitignore vendored Normal file
View File

@ -0,0 +1,25 @@
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
*.pkg
# Test binary, built with `go test -c`
*.test
# Output of the go coverage tool, specifically when used with LiteIDE
*.out
# Dependency directories (remove the comment below to include it)
# vendor/
# Go workspace file
go.work
go.work.sum
# env file
.env
.idea
.vscode

9
format.go Normal file
View File

@ -0,0 +1,9 @@
package nixbuild
const (
nixosSuffix0 = "#nixosConfigurations."
nixosSuffix1 = ".config.system.build.toplevel"
)
// NixOSInstallable returns the nixos installable for a given flake and host.
func NixOSInstallable(flake, host string) string { return flake + nixosSuffix0 + host + nixosSuffix1 }

24
format_test.go Normal file
View File

@ -0,0 +1,24 @@
package nixbuild_test
import (
"testing"
"git.gensokyo.uk/yonah/nixbuild"
)
func TestInstallable(t *testing.T) {
testCases := []struct {
name, flake, host, want string
}{
{"satori", "/var/lib/persist/nixos", "satori", "/var/lib/persist/nixos#nixosConfigurations.satori.config.system.build.toplevel"},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
got := nixbuild.NixOSInstallable(tc.flake, tc.host)
if got != tc.want {
t.Errorf("Installable(%q, %q): %q, want %q",
tc.flake, tc.host, got, tc.want)
}
})
}
}

3
go.mod Normal file
View File

@ -0,0 +1,3 @@
module git.gensokyo.uk/yonah/nixbuild
go 1.24.4