Skip to content

Commit

Permalink
chore: nixos
Browse files Browse the repository at this point in the history
  • Loading branch information
dezren39 committed Jul 12, 2024
1 parent b803df9 commit 6c01d46
Show file tree
Hide file tree
Showing 8 changed files with 147 additions and 122 deletions.
7 changes: 3 additions & 4 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -179,7 +179,6 @@
};
devShell.${system} = devShellInner;
};
# hydra
# hydra
# content addressible
}

1 change: 1 addition & 0 deletions modules/nixos/configuration.nix → lib/configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@
e2fsprogs
asciinema
# charm stuff?
statix

oils-for-unix # todo: osh default shell?
# overlays # todo- move into user
Expand Down
21 changes: 13 additions & 8 deletions lib/rebuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
105 changes: 60 additions & 45 deletions pkgs/colorschemes/generator.nix
Original file line number Diff line number Diff line change
@@ -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
39 changes: 20 additions & 19 deletions pkgs/formats/default.nix
Original file line number Diff line number Diff line change
@@ -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;
};
}
40 changes: 20 additions & 20 deletions pkgs/pass-wofi/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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";
};
}
39 changes: 20 additions & 19 deletions pkgs/shellcolord/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 ];
};
}
17 changes: 10 additions & 7 deletions pkgs/vim/rebuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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

0 comments on commit 6c01d46

Please sign in to comment.