From 6c01d46898445e4992473dee0112ff9492ea344b Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Fri, 12 Jul 2024 03:36:17 -0500 Subject: [PATCH] chore: nixos --- flake.nix | 7 +- {modules/nixos => lib}/configuration.nix | 1 + lib/rebuild.sh | 21 +++-- pkgs/colorschemes/generator.nix | 105 +++++++++++++---------- pkgs/formats/default.nix | 39 +++++---- pkgs/pass-wofi/default.nix | 40 ++++----- pkgs/shellcolord/default.nix | 39 +++++---- pkgs/vim/rebuild.sh | 17 ++-- 8 files changed, 147 insertions(+), 122 deletions(-) rename {modules/nixos => lib}/configuration.nix (99%) diff --git a/flake.nix b/flake.nix index b8cb02a1..41473385 100755 --- a/flake.nix +++ b/flake.nix @@ -113,13 +113,13 @@ }; system.stateVersion = stateVersion; } - ./modules/configuration.nix # this relies on magic overlays, ? todo: remove overlays from configuration.nix? then add inline let overlay configuration right here below this moduleArrayList. + ./lib/configuration.nix # this relies on magic overlays, ? todo: remove overlays from configuration.nix? then add inline let overlay configuration right here below this moduleArrayList. #sops-nix.nixosModules.sops #./modules/sops.nix ]; # overlayNixosModules = ? hyprlandNixosModules = [ - (import ./modules/hyprland.nix) # hyprland = would use flake for hyprland master but had annoying warning about waybar? todo try again. prefer flake. the config for this is setup in homeManager for reasons. could be brought out to nixos module would probably fit better due to my agonies + (import ./modules/nixos/hyprland.nix) # hyprland = would use flake for hyprland master but had annoying warning about waybar? todo try again. prefer flake. the config for this is setup in homeManager for reasons. could be brought out to nixos module would probably fit better due to my agonies # (import ./modules/nm-applet.nix) ]; system = "x86_64-linux"; @@ -179,7 +179,6 @@ }; devShell.${system} = devShellInner; }; - # hydra + # hydra # content addressible } - diff --git a/modules/nixos/configuration.nix b/lib/configuration.nix similarity index 99% rename from modules/nixos/configuration.nix rename to lib/configuration.nix index eb7febbe..f95b7ab3 100755 --- a/modules/nixos/configuration.nix +++ b/lib/configuration.nix @@ -284,6 +284,7 @@ e2fsprogs asciinema # charm stuff? + statix oils-for-unix # todo: osh default shell? # overlays # todo- move into user diff --git a/lib/rebuild.sh b/lib/rebuild.sh index b375e6f4..d639c44f 100755 --- a/lib/rebuild.sh +++ b/lib/rebuild.sh @@ -10,33 +10,38 @@ cd "${script_dir}" || exit 1 git add . # Loop through each directory in flakes -for dir in "${script_dir}"/flakes/*; do +for dir in "${script_dir}"/pkgs/*; do if [[ -d ${dir} ]]; then cd "${dir}" || exit 1 # If a rebuild --json script exists, execute it - if [[ -f "./rebuild --json.sh" ]]; then - chmod +x ./rebuild --json.sh - ./rebuild --json.sh + if [[ -f "./rebuild.sh" ]]; then + chmod +x ./rebuild.sh + ./rebuild.sh fi # todo: update-ref instead of update sometimes - nix flake update --print-build-logs --verbose --keep-going --log-format internal-json --fallback --show-trace |& nom --json - cd "${script_dir}" || exit 1 + if [[ -f "./flake.nix" ]]; then + nix flake update --print-build-logs --verbose --keep-going --log-format internal-json --fallback --show-trace |& nom --json + cd "${script_dir}" || exit 1 + fi fi done git add . # todo: update-ref instead of update sometimes + +if [[ -f "./flake.nix" ]]; then nix flake update --print-build-logs --verbose --keep-going --log-format internal-json --fallback --show-trace |& nom --json git add . sudo nixos-rebuild --json switch --json --upgrade --json --print-build-logs --verbose --keep-going --log-format internal-json --fallback --show-trace --flake '.' |& nom --json +fi #TODO: don't do cachix if not setup #nom flake archive --print-build-logs --verbose --keep-going --log-format internal-json --fallback --show-trace --json | jq -r '.path,(.inputs|to_entries[].value.path)' | cachix push binary # todo: make optional -for dir in "${script_dir}"/flakes/*; do +for dir in "${script_dir}"/pkgs/*; do if [[ -d ${dir} ]]; then cd "${dir}" || exit 1 - if [[ -f "./rebuild --json.sh" ]]; then + if [[ -f "./rebuild.sh" ]]; then echo "" # nom flake archive --print-build-logs --verbose --keep-going --log-format internal-json --fallback --show-trace --json | jq -r '.path,(.inputs|to_entries[].value.path)' | cachix push binary # todo: make optional fi diff --git a/pkgs/colorschemes/generator.nix b/pkgs/colorschemes/generator.nix index dc442e97..ebf5e33f 100644 --- a/pkgs/colorschemes/generator.nix +++ b/pkgs/colorschemes/generator.nix @@ -1,52 +1,67 @@ -{pkgs, ...}: let +{ pkgs, ... }: +let inherit (pkgs) lib; matugen = import (fetchTarball { url = "https://github.com/InioX/matugen/archive/3040fe974b94bc70b49e6c3b868a8eb1c7b294a3.tar.gz"; sha256 = "sha256:0v7np4294fzwxmgf7pjcxvky63lrq1ajim1b8ywbp47wy9k0pcgs"; - }) {inherit pkgs;}; - generateColorscheme = name: source: let - schemeTypes = ["content" "expressive" "fidelity" "fruit-salad" "monochrome" "neutral" "rainbow" "tonal-spot"]; - isHexColor = c: lib.isString c && (builtins.match "#([0-9a-fA-F]{3}){1,2}" c) != null; + }) { inherit pkgs; }; + generateColorscheme = + name: source: + let + schemeTypes = [ + "content" + "expressive" + "fidelity" + "fruit-salad" + "monochrome" + "neutral" + "rainbow" + "tonal-spot" + ]; + isHexColor = c: lib.isString c && (builtins.match "#([0-9a-fA-F]{3}){1,2}" c) != null; - config = (pkgs.formats.toml {}).generate "config.toml" { - templates = {}; - config = { - colors_to_harmonize = { - light-red = "#d03e3e"; - light-orange = "#d7691d"; - light-yellow = "#ad8200"; - light-green = "#31861f"; - light-cyan = "#00998f"; - light-blue = "#3173c5"; - light-magenta = "#9e57c2"; - dark-red = "#e15d67"; - dark-orange = "#fc804e"; - dark-yellow = "#e1b31a"; - dark-green = "#5db129"; - dark-cyan = "#21c992"; - dark-blue = "#00a3f2"; - dark-magenta = "#b46ee0"; + config = (pkgs.formats.toml { }).generate "config.toml" { + templates = { }; + config = { + colors_to_harmonize = { + light-red = "#d03e3e"; + light-orange = "#d7691d"; + light-yellow = "#ad8200"; + light-green = "#31861f"; + light-cyan = "#00998f"; + light-blue = "#3173c5"; + light-magenta = "#9e57c2"; + dark-red = "#e15d67"; + dark-orange = "#fc804e"; + dark-yellow = "#e1b31a"; + dark-green = "#5db129"; + dark-cyan = "#21c992"; + dark-blue = "#00a3f2"; + dark-magenta = "#b46ee0"; + }; }; }; - }; - in - pkgs.runCommand "colorscheme-${name}" { - # __contentAddressed = true; - passthru = let - drv = generateColorscheme name source; - in { - inherit schemeTypes; - # Incurs IFD - imported = lib.genAttrs schemeTypes (scheme: lib.importJSON "${drv}/${scheme}.json"); - }; - } '' - mkdir "$out" -p - for type in ${lib.concatStringsSep " " schemeTypes}; do - ${matugen}/bin/matugen ${ - if (isHexColor source) - then "color hex" - else "image" - } --config ${config} -j hex -t "scheme-$type" "${source}" > "$out/$type.json" - done - ''; -in generateColorscheme + in + pkgs.runCommand "colorscheme-${name}" + { + # __contentAddressed = true; + passthru = + let + drv = generateColorscheme name source; + in + { + inherit schemeTypes; + # Incurs IFD + imported = lib.genAttrs schemeTypes (scheme: lib.importJSON "${drv}/${scheme}.json"); + }; + } + '' + mkdir "$out" -p + for type in ${lib.concatStringsSep " " schemeTypes}; do + ${matugen}/bin/matugen ${ + if (isHexColor source) then "color hex" else "image" + } --config ${config} -j hex -t "scheme-$type" "${source}" > "$out/$type.json" + done + ''; +in +generateColorscheme diff --git a/pkgs/formats/default.nix b/pkgs/formats/default.nix index 8565c178..941fac36 100644 --- a/pkgs/formats/default.nix +++ b/pkgs/formats/default.nix @@ -1,22 +1,23 @@ -{pkgs}: { - gzipJson = {}: { - generate = name: value: - pkgs.callPackage ( - { - runCommand, - gzip, - }: +{ pkgs }: +{ + gzipJson = + { }: + { + generate = + name: value: + pkgs.callPackage ( + { runCommand, gzip }: runCommand name - { - nativeBuildInputs = [gzip]; - value = builtins.toJSON value; - passAsFile = ["value"]; - } - '' - gzip "$valuePath" -c > "$out" - '' - ) {}; + { + nativeBuildInputs = [ gzip ]; + value = builtins.toJSON value; + passAsFile = [ "value" ]; + } + '' + gzip "$valuePath" -c > "$out" + '' + ) { }; - type = (pkgs.formats.json {}).type; - }; + type = (pkgs.formats.json { }).type; + }; } diff --git a/pkgs/pass-wofi/default.nix b/pkgs/pass-wofi/default.nix index 1a8d57b0..29d388ea 100644 --- a/pkgs/pass-wofi/default.nix +++ b/pkgs/pass-wofi/default.nix @@ -12,21 +12,21 @@ gnused, coreutils, }: - stdenv.mkDerivation { - name = "pass-wofi"; - version = "1.0"; - src = ./pass-wofi.sh; +stdenv.mkDerivation { + name = "pass-wofi"; + version = "1.0"; + src = ./pass-wofi.sh; - nativeBuildInputs = [makeWrapper]; + nativeBuildInputs = [ makeWrapper ]; - dontUnpack = true; - dontBuild = true; - dontConfigure = true; + dontUnpack = true; + dontBuild = true; + dontConfigure = true; - installPhase = '' - install -Dm 0755 $src $out/bin/pass-wofi - wrapProgram $out/bin/pass-wofi --prefix PATH ':' \ - "${ + installPhase = '' + install -Dm 0755 $src $out/bin/pass-wofi + wrapProgram $out/bin/pass-wofi --prefix PATH ':' \ + "${ lib.makeBinPath [ pass jq @@ -39,12 +39,12 @@ coreutils ] }" - ''; + ''; - meta = { - description = "A wofi graphical menu for pass"; - license = lib.licenses.mit; - platforms = lib.platforms.all; - mainProgram = "pass-wofi"; - }; - } + meta = { + description = "A wofi graphical menu for pass"; + license = lib.licenses.mit; + platforms = lib.platforms.all; + mainProgram = "pass-wofi"; + }; +} diff --git a/pkgs/shellcolord/default.nix b/pkgs/shellcolord/default.nix index c4c904cd..b0eda3f6 100644 --- a/pkgs/shellcolord/default.nix +++ b/pkgs/shellcolord/default.nix @@ -2,26 +2,27 @@ lib, stdenv, fetchFromSourcehut, -}: let +}: +let pname = "shellcolord"; in - stdenv.mkDerivation { - inherit pname; - version = "0.1"; - src = fetchFromSourcehut { - owner = "~misterio"; - repo = pname; - rev = "c761072952bba8bdc21b906fdc941b9ae5ac5432"; - sha256 = "sha256-SLMAZy9UxQOA+2YhnryJ5ZvMXOf/Bxv0E8gIbP32XfE="; - }; +stdenv.mkDerivation { + inherit pname; + version = "0.1"; + src = fetchFromSourcehut { + owner = "~misterio"; + repo = pname; + rev = "c761072952bba8bdc21b906fdc941b9ae5ac5432"; + sha256 = "sha256-SLMAZy9UxQOA+2YhnryJ5ZvMXOf/Bxv0E8gIbP32XfE="; + }; - makeFlags = ["PREFIX=$(out)"]; + makeFlags = [ "PREFIX=$(out)" ]; - meta = with lib; { - description = "A daemon that themes your shell remotely"; - homepage = "https://git.sr.ht/~misterio/shellcolord"; - license = licenses.unlicense; - platforms = platforms.all; - maintainers = with maintainers; [misterio77]; - }; - } + meta = with lib; { + description = "A daemon that themes your shell remotely"; + homepage = "https://git.sr.ht/~misterio/shellcolord"; + license = licenses.unlicense; + platforms = platforms.all; + maintainers = with maintainers; [ misterio77 ]; + }; +} diff --git a/pkgs/vim/rebuild.sh b/pkgs/vim/rebuild.sh index 5bbdd200..1dca4455 100755 --- a/pkgs/vim/rebuild.sh +++ b/pkgs/vim/rebuild.sh @@ -17,12 +17,12 @@ for dir in "${script_dir}"/config/*; do fi cd "${dir}" || exit 1 # If a rebuild --json script exists, execute it - if [[ -f "./rebuild --json.sh" ]]; then - chmod +x ./rebuild --json.sh - ./rebuild --json.sh + if [[ -f "./rebuild.sh" ]]; then + chmod +x ./rebuild.sh + ./rebuild.sh fi - nix flake update --print-build-logs --verbose --keep-going --log-format internal-json --fallback --show-trace |& nom --json - nix build --json --print-out-paths --print-build-logs --verbose --keep-going --log-format internal-json --fallback --show-trace |& nom --json + nix flake update --print-build-logs --verbose --keep-going --log-format internal-json --fallback --show-trace |& nom --json + nix build --json --print-out-paths --print-build-logs --verbose --keep-going --log-format internal-json --fallback --show-trace |& nom --json #nom build --json --print-out-paths --json --print-build-logs --verbose --keep-going --log-format internal-json --fallback --show-trace --json | # jq -r '.[].outputs | to_entries[].value' | # cachix push binary @@ -34,10 +34,12 @@ for dir in "${script_dir}"/config/*; do done git add . + +if [[ -f "./flake.nix" ]]; then # TODO: sometimes do update-ref instead of update -nix flake update --print-build-logs --verbose --keep-going --log-format internal-json --fallback --show-trace |& nom --json +nix flake update --print-build-logs --verbose --keep-going --log-format internal-json --fallback --show-trace |& nom --json # TODO: skip cachix if not setup -nix build --json --print-out-paths --json --print-build-logs --verbose --keep-going --log-format internal-json --fallback --show-trace |& nom --json +nix build --json --print-out-paths --json --print-build-logs --verbose --keep-going --log-format internal-json --fallback --show-trace |& nom --json #nom build --json --print-out-paths --json --print-build-logs --verbose --keep-going --log-format internal-json --fallback --show-trace --json | # jq -r '.[].outputs | to_entries[].value' | # cachix push binary @@ -46,3 +48,4 @@ nix build --json --print-out-paths --json --print-build-logs --verbose --keep-go # cachix push binary # todo: make optional git add . +fi