format: format nixos installable
This commit is contained in:
commit
db93b6be6c
25
.gitignore
vendored
Normal file
25
.gitignore
vendored
Normal 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
9
format.go
Normal 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
24
format_test.go
Normal 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)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user