forked from tangled.org/core
Monorepo for Tangled — https://tangled.org
at master 1.4 kB view raw
1package nixery 2 3import ( 4 "fmt" 5 "strings" 6) 7 8func nixConfStep() Step { 9 setupCmd := `mkdir -p /etc/nix 10echo 'extra-experimental-features = nix-command flakes' >> /etc/nix/nix.conf 11echo 'build-users-group = ' >> /etc/nix/nix.conf` 12 return Step{ 13 command: setupCmd, 14 name: "Configure Nix", 15 } 16} 17 18// dependencyStep processes dependencies defined in the workflow. 19// For dependencies using a custom registry (i.e. not nixpkgs), it collects 20// all packages and adds a single 'nix profile install' step to the 21// beginning of the workflow's step list. 22func dependencyStep(deps map[string][]string) *Step { 23 var customPackages []string 24 25 for registry, packages := range deps { 26 if registry == "nixpkgs" { 27 continue 28 } 29 30 if len(packages) == 0 { 31 customPackages = append(customPackages, registry) 32 } 33 // collect packages from custom registries 34 for _, pkg := range packages { 35 customPackages = append(customPackages, fmt.Sprintf("'%s#%s'", registry, pkg)) 36 } 37 } 38 39 if len(customPackages) > 0 { 40 installCmd := "nix --extra-experimental-features nix-command --extra-experimental-features flakes profile install" 41 cmd := fmt.Sprintf("%s %s", installCmd, strings.Join(customPackages, " ")) 42 installStep := Step{ 43 command: cmd, 44 name: "Install custom dependencies", 45 environment: map[string]string{ 46 "NIX_NO_COLOR": "1", 47 "NIX_SHOW_DOWNLOAD_PROGRESS": "0", 48 }, 49 } 50 return &installStep 51 } 52 return nil 53}