mirror of
https://github.com/daylinmorgan/oizys.git
synced 2024-12-22 14:20:44 -06:00
try out styx as a main repo
This commit is contained in:
parent
d8972aae6c
commit
93f13d2049
4 changed files with 32 additions and 16 deletions
|
@ -23,8 +23,10 @@
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
lib = import ./lib {inherit inputs nixpkgs;};
|
lib = import ./lib {inherit inputs nixpkgs;};
|
||||||
|
inherit (lib) findModules mapHosts shToPkg;
|
||||||
in {
|
in {
|
||||||
nixosModules = builtins.listToAttrs (lib.findModules ./modules);
|
nixosModules = findModules ./modules;
|
||||||
nixosConfigurations = lib.mapHosts ./hosts;
|
nixosConfigurations = mapHosts ./hosts;
|
||||||
|
packages = shToPkg ./styx;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,10 +3,25 @@
|
||||||
nixpkgs,
|
nixpkgs,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (builtins) concatLists attrValues mapAttrs elemAt match readDir filter;
|
inherit (builtins) concatLists attrValues mapAttrs elemAt match readDir filter listToAttrs baseNameOf readFile;
|
||||||
inherit (nixpkgs.lib) hasSuffix nixosSystem;
|
inherit (nixpkgs.lib) hasSuffix nixosSystem genAttrs;
|
||||||
inherit (nixpkgs.lib.filesystem) listFilesRecursive;
|
inherit (nixpkgs.lib.filesystem) listFilesRecursive;
|
||||||
|
|
||||||
|
# https://xeiaso.net/blog/nix-flakes-1-2022-02-21/
|
||||||
|
supportedSystems = ["x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin"];
|
||||||
|
forAllSystems = genAttrs supportedSystems;
|
||||||
|
nixpkgsFor = forAllSystems (system: import nixpkgs {inherit system;});
|
||||||
in rec {
|
in rec {
|
||||||
|
shToPkg = path:
|
||||||
|
forAllSystems (
|
||||||
|
system: let
|
||||||
|
name = baseNameOf path;
|
||||||
|
pkgs = nixpkgsFor.${system};
|
||||||
|
in {
|
||||||
|
${name} = pkgs.writeScriptBin name (readFile path);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
isNixFile = path: hasSuffix ".nix" path;
|
isNixFile = path: hasSuffix ".nix" path;
|
||||||
|
|
||||||
mkSystem = hostname:
|
mkSystem = hostname:
|
||||||
|
@ -14,7 +29,7 @@ in rec {
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
modules =
|
modules =
|
||||||
[../modules/roles/common.nix]
|
[../modules/roles/common.nix]
|
||||||
++ builtins.filter isNixFile (listFilesRecursive (../. + "/hosts/${hostname}"));
|
++ filter isNixFile (listFilesRecursive (../. + "/hosts/${hostname}"));
|
||||||
specialArgs = {inherit inputs;};
|
specialArgs = {inherit inputs;};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -23,8 +38,9 @@ in rec {
|
||||||
(name: _: mkSystem name)
|
(name: _: mkSystem name)
|
||||||
(readDir dir);
|
(readDir dir);
|
||||||
|
|
||||||
|
findModules = modulesPath: listToAttrs (findModulesList modulesPath);
|
||||||
# https://github.com/balsoft/nixos-config/blob/73cc2c3a8bb62a9c3980a16ae70b2e97af6e1abd/flake.nix#L109-L120
|
# https://github.com/balsoft/nixos-config/blob/73cc2c3a8bb62a9c3980a16ae70b2e97af6e1abd/flake.nix#L109-L120
|
||||||
findModules = dir:
|
findModulesList = dir:
|
||||||
concatLists (attrValues (mapAttrs
|
concatLists (attrValues (mapAttrs
|
||||||
(name: type:
|
(name: type:
|
||||||
if type == "regular"
|
if type == "regular"
|
||||||
|
@ -43,5 +59,5 @@ in rec {
|
||||||
value = dir + "/${name}";
|
value = dir + "/${name}";
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
else findModules (dir + "/${name}")) (readDir dir)));
|
else findModulesList (dir + "/${name}")) (readDir dir)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
{pkgs, ...}: {
|
|
||||||
environment.systemPackages = with pkgs; [
|
|
||||||
(writeScriptBin "styx" (builtins.readFile ./styx))
|
|
||||||
];
|
|
||||||
}
|
|
|
@ -5,7 +5,7 @@ set -e
|
||||||
# rewrite as python script?
|
# rewrite as python script?
|
||||||
|
|
||||||
HOSTNAME=${HOSTNAME:-$(hostname)}
|
HOSTNAME=${HOSTNAME:-$(hostname)}
|
||||||
FLAKE_PATH=${FLAKE_PATH-:$HOME/nixcfg}
|
FLAKE_PATH=${FLAKE_PATH:-$HOME/nixcfg}
|
||||||
|
|
||||||
DIM="$(tput dim)"
|
DIM="$(tput dim)"
|
||||||
BOLD="$(tput bold)"
|
BOLD="$(tput bold)"
|
||||||
|
@ -30,7 +30,6 @@ styx <cmd> [-h]
|
||||||
${DIM}sister moon to nix on pluto
|
${DIM}sister moon to nix on pluto
|
||||||
sister software to nix in this repo${RESET}
|
sister software to nix in this repo${RESET}
|
||||||
|
|
||||||
pass additional args with -- --key value
|
|
||||||
${BOLD}commands${RESET}:
|
${BOLD}commands${RESET}:
|
||||||
EOF
|
EOF
|
||||||
printf "${GREEN}%8s${RESET} | ${YELLOW}%s${RESET}\n" \
|
printf "${GREEN}%8s${RESET} | ${YELLOW}%s${RESET}\n" \
|
||||||
|
@ -38,7 +37,8 @@ EOF
|
||||||
build "build and monitor with nom" \
|
build "build and monitor with nom" \
|
||||||
boot "evaluate flake for next boot" \
|
boot "evaluate flake for next boot" \
|
||||||
switch "perform nixos rebuild" \
|
switch "perform nixos rebuild" \
|
||||||
store "run some store cleanup"
|
store "run some store cleanup" \
|
||||||
|
cache "nix build and push to daylin.cachix.org"
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,6 +99,10 @@ while [[ $# -gt 0 ]]; do
|
||||||
;;
|
;;
|
||||||
--help)
|
--help)
|
||||||
help
|
help
|
||||||
|
;;
|
||||||
|
--)
|
||||||
|
shift
|
||||||
|
break
|
||||||
;;
|
;;
|
||||||
-*,--*)
|
-*,--*)
|
||||||
error "unknown flag: ${BOLD}$1${RESET}"
|
error "unknown flag: ${BOLD}$1${RESET}"
|
||||||
|
@ -116,5 +120,4 @@ if [[ $# -gt 0 ]]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$cmd "$@"
|
$cmd "$@"
|
Loading…
Reference in a new issue