diff --git a/flake.nix b/flake.nix index eb6ed3d..fb3e152 100644 --- a/flake.nix +++ b/flake.nix @@ -23,8 +23,11 @@ ... }: let lib = import ./lib {inherit inputs nixpkgs;}; + inherit (lib) findModules nixpkgsFor mapHosts; + inherit (builtins) listToAttrs readFile; in { - nixosModules = builtins.listToAttrs (lib.findModules ./modules); - nixosConfigurations = lib.mapHosts ./hosts; + nixosModules = listToAttrs (findModules ./modules); + nixosConfigurations = mapHosts ./hosts; + packages.x86_64-linux.styx = (nixpkgsFor "x86_64-linux").writeScriptBin "styx" (readFile ./styx); }; } diff --git a/lib/default.nix b/lib/default.nix index 84ed405..8da1ad7 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -7,6 +7,8 @@ inherit (nixpkgs.lib) hasSuffix nixosSystem; inherit (nixpkgs.lib.filesystem) listFilesRecursive; in rec { + nixpkgsFor = system: import nixpkgs {inherit system;}; + isNixFile = path: hasSuffix ".nix" path; mkSystem = hostname: diff --git a/modules/styx/default.nix b/modules/styx/default.nix deleted file mode 100644 index a79d803..0000000 --- a/modules/styx/default.nix +++ /dev/null @@ -1,5 +0,0 @@ -{pkgs, ...}: { - environment.systemPackages = with pkgs; [ - (writeScriptBin "styx" (builtins.readFile ./styx)) - ]; -} diff --git a/modules/styx/styx b/styx similarity index 92% rename from modules/styx/styx rename to styx index 849fcb8..564b028 100755 --- a/modules/styx/styx +++ b/styx @@ -5,7 +5,7 @@ set -e # rewrite as python script? HOSTNAME=${HOSTNAME:-$(hostname)} -FLAKE_PATH=${FLAKE_PATH-:$HOME/nixcfg} +FLAKE_PATH=${FLAKE_PATH:-$HOME/nixcfg} DIM="$(tput dim)" BOLD="$(tput bold)" @@ -30,7 +30,6 @@ styx [-h] ${DIM}sister moon to nix on pluto sister software to nix in this repo${RESET} - pass additional args with -- --key value ${BOLD}commands${RESET}: EOF printf "${GREEN}%8s${RESET} | ${YELLOW}%s${RESET}\n" \ @@ -38,7 +37,8 @@ EOF build "build and monitor with nom" \ boot "evaluate flake for next boot" \ switch "perform nixos rebuild" \ - store "run some store cleanup" + store "run some store cleanup" \ + cache "nix build and push to daylin.cachix.org" exit } @@ -99,6 +99,10 @@ while [[ $# -gt 0 ]]; do ;; --help) help + ;; + --) + shift + break ;; -*,--*) error "unknown flag: ${BOLD}$1${RESET}" @@ -116,5 +120,4 @@ if [[ $# -gt 0 ]]; then fi - $cmd "$@"