diff --git a/devshell/default.nix b/devshell/default.nix index fd07a4f..2ed3895 100644 --- a/devshell/default.nix +++ b/devshell/default.nix @@ -1,8 +1,4 @@ -{ - system, - pkgs, - self -}: +{ system, pkgs, self, ... }: (import ./dev { inherit self system pkgs; }) // { c = import ./c.nix { inherit self system pkgs; }; diff --git a/flake.nix b/flake.nix index 932a84c..dc7780d 100644 --- a/flake.nix +++ b/flake.nix @@ -68,57 +68,15 @@ system, pkgs, }: { - packages.${system} = import ./package { inherit system self pkgs inputs; }; - devShells.${system} = import ./devshell { inherit system self pkgs; }; - legacyPackages.${system} = import ./legacy { - inherit system self; - pkgs = import nixpkgs { inherit system; }; - }; - nixosConfigurations = { - "devvm-manual|${system}" = import ./nixos/system/devvm-manual/default.nix - { inherit flake self inputs system; }; - "devvm-hemar|${system}" = import ./nixos/system/devvm-hemar/default.nix - { inherit flake self inputs system; }; - }; - - #nixosTests = let - # testLib = import (nixpkgs + "/nixos/lib/testing-python.nix") { inherit pkgs; }; - #in { - # "hardware/lenovo-ideapad-15arh7" = testLib.makeTest { - # name = "hardware/lenovo-ideapad-15arh7"; - # nodes.machine = { ... }: { - # imports = [ self.nixosModules.hectic ]; - # services.hardware.lenovo-ideapad-15arh7.enable = true; - # }; - # testScript = '' - # start_all() - # machine.wait_for_unit("my-service.service") - # machine.succeed("journalctl -u my-service -b | grep -qi hello") - # ''; - # }; - #}; - - checks = let - mkSys = system: opts: - (nixpkgs.lib.nixosSystem { - inherit system; - modules = [ - self.nixosModules.hectic - { hectic.hardware.lenovo-ideapad-15arh7 = opts; } - ]; - }); - - cases = { - #enable = { enable = true; }; - #disabled = { enable = false; }; - #customFoo = { enable = true; foo = "bar"; }; - }; - in nixpkgs.lib.mapAttrs - (name: opts: (mkSys system opts).config.system.build.toplevel) cases; + packages.${system} = import ./package { inherit flake self inputs pkgs system; }; + devShells.${system} = import ./devshell { inherit flake self inputs pkgs system; }; + legacyPackages.${system} = import ./legacy { inherit flake self inputs pkgs system; }; + nixosConfigurations = { }; + checks.${system} = import ./test { inherit flake self inputs pkgs system; }; }) // { lib = self-lib; - overlays.default = import ./overlay { inherit flake self inputs nixpkgs; }; - nixosModules = import ./nixos/module { inherit flake self inputs nixpkgs; }; - templates = import ./template { inherit flake self inputs nixpkgs; }; + overlays.default = import ./overlay { inherit flake self inputs; }; + nixosModules = import ./nixos/module { inherit flake self inputs; }; + templates = import ./template { inherit flake self inputs; }; }; } diff --git a/legacy/default.nix b/legacy/default.nix index 973e287..0123e3d 100644 --- a/legacy/default.nix +++ b/legacy/default.nix @@ -1,7 +1,8 @@ -{ self, system, pkgs }: +{ pkgs, ... }: let - writers = pkgs.callPackage ./writer { }; + writers = pkgs.callPackage ./writer { }; in { + helpers = pkgs.callPackage ./helper { }; # NOTE(yukkop): duplicate writers in root of legacyPackages and writers due nixpkgs legacyPackages consistency writers = writers; } // writers diff --git a/legacy/helper/default.nix b/legacy/helper/default.nix new file mode 100644 index 0000000..5a68d32 --- /dev/null +++ b/legacy/helper/default.nix @@ -0,0 +1,3 @@ +{ callPackage }: { + posix-shell = callPackage ./posix-shell {}; +} diff --git a/legacy/helper/posix-shell/colors.sh b/legacy/helper/posix-shell/colors.sh new file mode 100644 index 0000000..627aad5 --- /dev/null +++ b/legacy/helper/posix-shell/colors.sh @@ -0,0 +1,54 @@ +NC='\033[0m' + +# Regular text colors +BLACK='\033[30m' +RED='\033[31m' +GREEN='\033[32m' +YELLOW='\033[33m' +BLUE='\033[34m' +MAGENTA='\033[35m' +CYAN='\033[36m' +WHITE='\033[37m' + +# Bright text colors +BBLACK='\033[90m' +BRED='\033[91m' +BGREEN='\033[92m' +BYELLOW='\033[93m' +BBLUE='\033[94m' +BMAGENTA='\033[95m' +BCYAN='\033[96m' +BWHITE='\033[97m' + +# Background colors +BG_BLACK='\033[40m' +BG_RED='\033[41m' +BG_GREEN='\033[42m' +BG_YELLOW='\033[43m' +BG_BLUE='\033[44m' +BG_MAGENTA='\033[45m' +BG_CYAN='\033[46m' +BG_WHITE='\033[47m' + +# Bright background colors +BG_BBLACK='\033[100m' +BG_BRED='\033[101m' +BG_BGREEN='\033[102m' +BG_BYELLOW='\033[103m' +BG_BBLUE='\033[104m' +BG_BMAGENTA='\033[105m' +BG_BCYAN='\033[106m' +BG_BWHITE='\033[107m' + +# Text effects +RESET='\033[0m' +BOLD='\033[1m' +DIM='\033[2m' +ITALIC='\033[3m' +UNDERLINE='\033[4m' +BLINK='\033[5m' +INVERSE='\033[7m' +HIDDEN='\033[8m' +STRIKE='\033[9m' + +: "$NC" "$BLACK" "$RED" "$GREEN" "$YELLOW" "$BLUE" "$MAGENTA" "$CYAN" "$WHITE" "$BBLACK" "$BRED" "$BGREEN" "$BYELLOW" "$BBLUE" "$BMAGENTA" "$BCYAN" "$BWHITE" "$BG_BLACK" "$BG_RED" "$BG_GREEN" "$BG_YELLOW" "$BG_BLUE" "$BG_MAGENTA" "$BG_CYAN" "$BG_WHITE" "$BG_BBLACK" "$BG_BRED" "$BG_BGREEN" "$BG_BYELLOW" "$BG_BBLUE" "$BG_BMAGENTA" "$BG_BCYAN" "$BG_BWHITE" "$RESET" "$BOLD" "$DIM" "$ITALIC" "$UNDERLINE" "$BLINK" "$INVERSE" "$HIDDEN" "$STRIKE" diff --git a/legacy/helper/posix-shell/default.nix b/legacy/helper/posix-shell/default.nix new file mode 100644 index 0000000..bbf9a31 --- /dev/null +++ b/legacy/helper/posix-shell/default.nix @@ -0,0 +1,15 @@ +{ dash, hectic }: let + shell = "${dash}/bin/dash"; + bashOptions = [ + "errexit" + "nounset" + ]; +in { + log = hectic.writeDash "log.sh" '' + ${builtins.readFile ./colors.sh} + ${builtins.readFile ./log.sh} + ''; + colors = hectic.writeDash "colors.sh" '' + ${builtins.readFile ./colors.sh} + ''; +} diff --git a/legacy/helper/posix-shell/log.sh b/legacy/helper/posix-shell/log.sh new file mode 100644 index 0000000..ef1fece --- /dev/null +++ b/legacy/helper/posix-shell/log.sh @@ -0,0 +1,21 @@ +#!/bin/dash + +log() { + level="${1:?}"; shift + case "$level" in + trace) color="$MAGENTA" ;; + debug) color="$BLUE" ;; + info) color="$GREEN" ;; + notice) color="$CYAN" ;; + warn) color="$YELLOW" ;; + error) color="$RED" ;; + *) color="$WHITE" ;; + esac + + + + # shellcheck disable=SC1003 + fmt="$(printf "%s" "${1:?}" | sed 's/\\033\[0m/''\'"$color"'/g')" + shift + printf "%b\n" "$color$fmt$NC" "$@" >&2 +} diff --git a/legacy/writer/default.nix b/legacy/writer/default.nix index 8b2f29a..bbfa9df 100644 --- a/legacy/writer/default.nix +++ b/legacy/writer/default.nix @@ -1,7 +1,6 @@ -{ - callPackage -}: rec { +{ callPackage }: rec { writeShellApplication = callPackage ./writeShellApplication.nix {}; + writeDash = callPackage ./writeDash.nix {}; writeC = callPackage ./writeC.nix {}; writeCBin = name: writeC "/bin/${name}"; writeMinCBin = name: includes: body: writeMinC "/bin/${name}" includes body; diff --git a/legacy/writer/writeDash.nix b/legacy/writer/writeDash.nix new file mode 100644 index 0000000..b82f480 --- /dev/null +++ b/legacy/writer/writeDash.nix @@ -0,0 +1,5 @@ + { dash, lib, writers }: name: argsOrScript: + if lib.isAttrs argsOrScript && !lib.isDerivation argsOrScript then + writers.makeScriptWriter (argsOrScript // { interpreter = "${lib.getExe dash}"; }) name + else + writers.makeScriptWriter { interpreter = "${lib.getExe dash}"; } name argsOrScript diff --git a/nixos/module/default.nix b/nixos/module/default.nix index 8b4d4aa..bc9f8d7 100644 --- a/nixos/module/default.nix +++ b/nixos/module/default.nix @@ -2,10 +2,9 @@ flake, self, inputs, - nixpkgs, }: with builtins; -with nixpkgs.lib; +with inputs.nixpkgs.lib; with self.lib; let # Combine hectic modules into one diff --git a/overlay/default.nix b/overlay/default.nix index 8f74480..7483f38 100644 --- a/overlay/default.nix +++ b/overlay/default.nix @@ -1,5 +1,5 @@ -{ inputs, self, nixpkgs, ... }: let - lib = nixpkgs.lib; +{ inputs, self, ... }: let + lib = inputs.nixpkgs.lib; in final: prev: ( let packages = self.packages.${prev.system}; diff --git a/package/default.nix b/package/default.nix index b24a827..80b641e 100644 --- a/package/default.nix +++ b/package/default.nix @@ -1,4 +1,4 @@ -{ self, system, pkgs, inputs }: let +{ self, system, pkgs, inputs, ... }: let rust = { nativeBuildInputs = [ pkgs.pkgsBuildHost.rust-bin.stable."1.81.0".default @@ -243,6 +243,7 @@ in { shellplot = pkgs.callPackage ./shellplot {}; sops = pkgs.callPackage ./sops.nix {}; onlinepubs2man = pkgs.callPackage ./onlinepubs2man {}; + migrator = pkgs.callPackage ./migratior {}; pg-17-ext-http = buildHttpExt pkgs "17"; pg-17-ext-smtp-client = buildSmtpExt pkgs "17"; pg-17-ext-plhaskell = buildPlHaskellExt pkgs "17";