feat(legacy): +writeDash +helpers
This commit is contained in:
@@ -1,8 +1,4 @@
|
|||||||
{
|
{ system, pkgs, self, ... }:
|
||||||
system,
|
|
||||||
pkgs,
|
|
||||||
self
|
|
||||||
}:
|
|
||||||
(import ./dev { inherit self system pkgs; })
|
(import ./dev { inherit self system pkgs; })
|
||||||
// {
|
// {
|
||||||
c = import ./c.nix { inherit self system pkgs; };
|
c = import ./c.nix { inherit self system pkgs; };
|
||||||
|
|||||||
58
flake.nix
58
flake.nix
@@ -68,57 +68,15 @@
|
|||||||
system,
|
system,
|
||||||
pkgs,
|
pkgs,
|
||||||
}: {
|
}: {
|
||||||
packages.${system} = import ./package { inherit system self pkgs inputs; };
|
packages.${system} = import ./package { inherit flake self inputs pkgs system; };
|
||||||
devShells.${system} = import ./devshell { inherit system self pkgs; };
|
devShells.${system} = import ./devshell { inherit flake self inputs pkgs system; };
|
||||||
legacyPackages.${system} = import ./legacy {
|
legacyPackages.${system} = import ./legacy { inherit flake self inputs pkgs system; };
|
||||||
inherit system self;
|
nixosConfigurations = { };
|
||||||
pkgs = import nixpkgs { inherit system; };
|
checks.${system} = import ./test { inherit flake self inputs pkgs 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;
|
|
||||||
}) // {
|
}) // {
|
||||||
lib = self-lib;
|
lib = self-lib;
|
||||||
overlays.default = import ./overlay { inherit flake self inputs nixpkgs; };
|
overlays.default = import ./overlay { inherit flake self inputs; };
|
||||||
nixosModules = import ./nixos/module { inherit flake self inputs nixpkgs; };
|
nixosModules = import ./nixos/module { inherit flake self inputs; };
|
||||||
templates = import ./template { inherit flake self inputs nixpkgs; };
|
templates = import ./template { inherit flake self inputs; };
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
{ self, system, pkgs }:
|
{ pkgs, ... }:
|
||||||
let
|
let
|
||||||
writers = pkgs.callPackage ./writer { };
|
writers = pkgs.callPackage ./writer { };
|
||||||
in {
|
in {
|
||||||
|
helpers = pkgs.callPackage ./helper { };
|
||||||
# NOTE(yukkop): duplicate writers in root of legacyPackages and writers due nixpkgs legacyPackages consistency
|
# NOTE(yukkop): duplicate writers in root of legacyPackages and writers due nixpkgs legacyPackages consistency
|
||||||
writers = writers;
|
writers = writers;
|
||||||
} // writers
|
} // writers
|
||||||
|
|||||||
3
legacy/helper/default.nix
Normal file
3
legacy/helper/default.nix
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{ callPackage }: {
|
||||||
|
posix-shell = callPackage ./posix-shell {};
|
||||||
|
}
|
||||||
54
legacy/helper/posix-shell/colors.sh
Normal file
54
legacy/helper/posix-shell/colors.sh
Normal file
@@ -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"
|
||||||
15
legacy/helper/posix-shell/default.nix
Normal file
15
legacy/helper/posix-shell/default.nix
Normal file
@@ -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}
|
||||||
|
'';
|
||||||
|
}
|
||||||
21
legacy/helper/posix-shell/log.sh
Normal file
21
legacy/helper/posix-shell/log.sh
Normal file
@@ -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
|
||||||
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
{
|
{ callPackage }: rec {
|
||||||
callPackage
|
|
||||||
}: rec {
|
|
||||||
writeShellApplication = callPackage ./writeShellApplication.nix {};
|
writeShellApplication = callPackage ./writeShellApplication.nix {};
|
||||||
|
writeDash = callPackage ./writeDash.nix {};
|
||||||
writeC = callPackage ./writeC.nix {};
|
writeC = callPackage ./writeC.nix {};
|
||||||
writeCBin = name: writeC "/bin/${name}";
|
writeCBin = name: writeC "/bin/${name}";
|
||||||
writeMinCBin = name: includes: body: writeMinC "/bin/${name}" includes body;
|
writeMinCBin = name: includes: body: writeMinC "/bin/${name}" includes body;
|
||||||
|
|||||||
5
legacy/writer/writeDash.nix
Normal file
5
legacy/writer/writeDash.nix
Normal file
@@ -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
|
||||||
@@ -2,10 +2,9 @@
|
|||||||
flake,
|
flake,
|
||||||
self,
|
self,
|
||||||
inputs,
|
inputs,
|
||||||
nixpkgs,
|
|
||||||
}:
|
}:
|
||||||
with builtins;
|
with builtins;
|
||||||
with nixpkgs.lib;
|
with inputs.nixpkgs.lib;
|
||||||
with self.lib;
|
with self.lib;
|
||||||
let
|
let
|
||||||
# Combine hectic modules into one
|
# Combine hectic modules into one
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{ inputs, self, nixpkgs, ... }: let
|
{ inputs, self, ... }: let
|
||||||
lib = nixpkgs.lib;
|
lib = inputs.nixpkgs.lib;
|
||||||
in final: prev: (
|
in final: prev: (
|
||||||
let
|
let
|
||||||
packages = self.packages.${prev.system};
|
packages = self.packages.${prev.system};
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
{ self, system, pkgs, inputs }: let
|
{ self, system, pkgs, inputs, ... }: let
|
||||||
rust = {
|
rust = {
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
pkgs.pkgsBuildHost.rust-bin.stable."1.81.0".default
|
pkgs.pkgsBuildHost.rust-bin.stable."1.81.0".default
|
||||||
@@ -243,6 +243,7 @@ in {
|
|||||||
shellplot = pkgs.callPackage ./shellplot {};
|
shellplot = pkgs.callPackage ./shellplot {};
|
||||||
sops = pkgs.callPackage ./sops.nix {};
|
sops = pkgs.callPackage ./sops.nix {};
|
||||||
onlinepubs2man = pkgs.callPackage ./onlinepubs2man {};
|
onlinepubs2man = pkgs.callPackage ./onlinepubs2man {};
|
||||||
|
migrator = pkgs.callPackage ./migratior {};
|
||||||
pg-17-ext-http = buildHttpExt pkgs "17";
|
pg-17-ext-http = buildHttpExt pkgs "17";
|
||||||
pg-17-ext-smtp-client = buildSmtpExt pkgs "17";
|
pg-17-ext-smtp-client = buildSmtpExt pkgs "17";
|
||||||
pg-17-ext-plhaskell = buildPlHaskellExt pkgs "17";
|
pg-17-ext-plhaskell = buildPlHaskellExt pkgs "17";
|
||||||
|
|||||||
Reference in New Issue
Block a user