diff --git a/doc/reference/source.md b/doc/reference/source.md index 4ce65773..74cf57d2 100644 --- a/doc/reference/source.md +++ b/doc/reference/source.md @@ -29,6 +29,7 @@ It needs to be one of * `fedora-http` * `funtoo-http` * `gentoo-http` +* `nixos-http` * `openeuler-http` * `opensuse-http` * `openwrt-http` diff --git a/shared/definition.go b/shared/definition.go index edb89437..1f96d2da 100644 --- a/shared/definition.go +++ b/shared/definition.go @@ -383,6 +383,7 @@ func (d *Definition) Validate() error { "rockylinux-http", "vyos-http", "slackware-http", + "nixos-http", } if !util.ValueInSlice(strings.TrimSpace(d.Source.Downloader), validDownloaders) { diff --git a/sources/nixos-http.go b/sources/nixos-http.go new file mode 100644 index 00000000..0ad3fbb8 --- /dev/null +++ b/sources/nixos-http.go @@ -0,0 +1,28 @@ +package sources + +import ( + "fmt" + "path/filepath" + + "github.com/lxc/distrobuilder/shared" +) + +type nixos struct { + common +} + +func (s *nixos) Run() error { + tarballURL := fmt.Sprintf("https://hydra.nixos.org/job/nixos/trunk-combined/nixos.lxdContainerImage.%s-linux/latest/download-by-type/file/system-tarball", s.definition.Image.ArchitectureMapped) + + fpath, err := s.DownloadHash(s.definition.Image, tarballURL, "", nil) + if err != nil { + return fmt.Errorf("Failed downloading tarball: %w", err) + } + + err = shared.Unpack(filepath.Join(fpath, "system-tarball"), s.rootfsDir) + if err != nil { + return fmt.Errorf("Failed unpacking rootfs: %w", err) + } + + return nil +} diff --git a/sources/source.go b/sources/source.go index 9e2e3b9e..906ec7a6 100644 --- a/sources/source.go +++ b/sources/source.go @@ -36,6 +36,7 @@ var downloaders = map[string]func() downloader{ "fedora-http": func() downloader { return &fedora{} }, "funtoo-http": func() downloader { return &funtoo{} }, "gentoo-http": func() downloader { return &gentoo{} }, + "nixos-http": func() downloader { return &nixos{} }, "openeuler-http": func() downloader { return &openEuler{} }, "opensuse-http": func() downloader { return &opensuse{} }, "openwrt-http": func() downloader { return &openwrt{} },