This repository has been archived by the owner on Dec 10, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from NobbZ/overhaul
Redesign how the system is built
- Loading branch information
Showing
154 changed files
with
5,577 additions
and
2,738 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
/result | ||
/result* |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
self, | ||
unstable, | ||
... | ||
}: let | ||
pkgs = unstable.legacyPackages.x86_64-linux; | ||
type = "app"; | ||
program = "${switch}/bin/switch"; | ||
|
||
nixosConfigs = pkgs.writeText "nixosConfigs" '' | ||
${__toJSON (__attrNames self.nixosConfigurations)} | ||
''; | ||
|
||
homeConfigs = pkgs.writeText "homeConfigs" '' | ||
${__toJSON (__attrNames self.homeConfigurations)} | ||
''; | ||
|
||
switch = pkgs.stdenv.mkDerivation { | ||
pname = "nobbz-flake-switcher"; | ||
version = "0.0.1"; | ||
|
||
buildInputs = [self.packages.x86_64-linux.zx]; | ||
|
||
src = ./.; | ||
|
||
installPhase = '' | ||
mkdir -p $out/{bin,lib} | ||
cat <<EOF > $out/bin/switch | ||
#!${pkgs.bash}/bin/bash | ||
exec $out/lib/switch.mjs --nixos ${nixosConfigs} --home ${homeConfigs} "\$@" | ||
EOF | ||
chmod ugo=rx $out/bin/switch | ||
install --mode=555 switch.mjs $out/lib/switch.mjs | ||
''; | ||
}; | ||
in {inherit type program;} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#!/usr/bin/env zx | ||
|
||
const info = (line) => console.log(chalk.yellow(line)); | ||
|
||
const trim = (str) => str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ''); | ||
|
||
console.log(process.argv.slice(2)) | ||
|
||
console.log(argv) | ||
|
||
info("loading nixos names") | ||
|
||
const nixosConfigs = JSON.parse(await fs.readFile(argv.nixos)) | ||
|
||
info("loading home manager names") | ||
|
||
const homeConfigs = JSON.parse(await fs.readFile(argv.home)) | ||
|
||
info("reading hostname"); | ||
|
||
const hostName = (await fs.readFile("/etc/hostname", "utf8")).trim() | ||
|
||
info("reading user"); | ||
|
||
const user = process.env.USER.trim(); | ||
|
||
info("finished reading inputs") | ||
|
||
const targets = [ | ||
`.#nixos/config/${hostName}`, | ||
`.#home/config/${user}@${hostName}`, | ||
] | ||
|
||
await $`nix build --keep-going --log-format bar-with-logs -v ${targets}` | ||
|
||
await fs.readdir('.') | ||
.then(dirs => Promise.all(dirs | ||
.filter(name => name.startsWith('result')) | ||
.map(async link => { | ||
const activate = `./${link}/bin/home-manager-generation`; | ||
|
||
await fs.stat(activate) | ||
.then(() => $`${activate}`) | ||
.catch(() => {}) | ||
}))) | ||
|
||
await $`sudo nixos-rebuild switch --flake .#${hostName}` | ||
|
||
await fs.readdir('.') | ||
.then(dirs => Promise.all(dirs | ||
.filter(name => name.startsWith('result')) | ||
.map(async link => await $`rm ${link}`))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
self, | ||
unstable, | ||
... | ||
}: let | ||
pkgs = unstable.legacyPackages.x86_64-linux; | ||
type = "app"; | ||
program = "${update}/bin/update"; | ||
|
||
update = pkgs.stdenv.mkDerivation { | ||
pname = "nobbz-flake-updater"; | ||
version = "0.0.1"; | ||
|
||
buildInputs = [self.packages.x86_64-linux.zx]; | ||
|
||
src = ./.; | ||
|
||
installPhase = '' | ||
mkdir -p $out/{bin,lib} | ||
cat <<EOF > $out/bin/update | ||
#!${pkgs.bash}/bin/bash | ||
exec $out/lib/update.mjs | ||
EOF | ||
chmod ugo=rx $out/bin/update | ||
install --mode=555 update.mjs $out/lib/update.mjs | ||
''; | ||
}; | ||
in {inherit type program;} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env zx | ||
|
||
await $`nix flake update --commit-lock-file` |
Oops, something went wrong.