Skip to content

Commit

Permalink
Merge pull request #775 from stgraber/main
Browse files Browse the repository at this point in the history
sources: Add NixOS
  • Loading branch information
monstermunchkin authored Oct 16, 2023
2 parents b0313f0 + c484058 commit 401041e
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc/reference/source.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ It needs to be one of
* `fedora-http`
* `funtoo-http`
* `gentoo-http`
* `nixos-http`
* `openeuler-http`
* `opensuse-http`
* `openwrt-http`
Expand Down
1 change: 1 addition & 0 deletions shared/definition.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
28 changes: 28 additions & 0 deletions sources/nixos-http.go
Original file line number Diff line number Diff line change
@@ -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
}
1 change: 1 addition & 0 deletions sources/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{} },
Expand Down

0 comments on commit 401041e

Please sign in to comment.