cleanup code, migrate to modules + start rewriting ddt4all derivation

This commit is contained in:
Franek 2025-03-23 22:25:17 +01:00
parent cfd21c973d
commit f5f2478422
14 changed files with 217 additions and 248 deletions

View File

@ -1,4 +1,5 @@
* [ ] Simplify config
* [ ] Organize most common apps with modules
* [x] Organize most common apps with modules
* [ ] Migrate from pywal + apple-fonts to Stylix (theme, cursor, fonts, ...)
* [ ] Remove clutter
* [x] Remove clutter
* [ ] Fix DDT4ALL derivation/shell

View File

@ -1,42 +0,0 @@
{ pkgs, stdenv, fetchFromGitHub }:
let
python = pkgs.python3.withPackages (pkgs: with pkgs; [ pyqt5 pyqtwebengine pyusb crcmod pyserial ]);
in stdenv.mkDerivation rec {
pname = "ddt4all";
version = "1.0.0";
src = fetchFromGitHub {
owner = "cedricp";
repo = "ddt4all";
rev = "master";
sha256 = "sha256-1D1fnnFWxBV6sZkfbBc7a/7DSZvZtXeEYM9fRsQ7Ag0=";
};
nativeBuildInputs = [
python
pkgs.libsForQt5.qt5.wrapQtAppsHook
pkgs.libsForQt5.qt5.qttools
pkgs.which
];
propagatedBuildInputs = [
python
pkgs.libsForQt5.qt5.qtbase
pkgs.libsForQt5.qt5.qttools
];
configurePhase = ''
runHook preConfigure
wrapQtAppsHook
runHook postConfigure
'';
buildPhase = "";
installPhase = ''
mkdir -p $out/bin
cp -r * $out/
ln -s $out/main.py $out/bin/ddt4all
'';
}

View File

@ -16,7 +16,20 @@
fingerprint-sensor.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { self, ... }: {
outputs = { self, nixpkgs, ... }: let
forAllSystems = nixpkgs.lib.genAttrs [
"aarch64-linux"
"x86_64-linux"
"aarch64-darwin"
];
in {
nixosConfigurations = import ./hosts { inherit self; };
devShells = forAllSystems ( system:
let
pkgs = nixpkgs.legacyPackages.${system};
in {
ddt4all = import ./shells/ddt4all.nix { inherit pkgs; };
}
);
};
}

View File

@ -2,21 +2,29 @@
let
inherit (self) inputs;
system = "x86_64-linux";
homeDir = self + /profiles;
pkgs = inputs.nixpkgs.legacyPackages.${system};
mkSystem = pkgs: hostname:
pkgs.lib.nixosSystem {
specialArgs = {
inherit inputs;
};
modules = [
./base-configuration.nix
./${hostname}
homeDir
inputs.home-manager.nixosModules.home-manager
];
};
mkSystem = {
system,
hostname,
useHomeManager ? true,
modules ? []
}: inputs.nixpkgs.lib.nixosSystem {
specialArgs = { inherit inputs; };
modules = [
./base-configuration.nix
./${hostname}
homeDir
] ++ (
if useHomeManager then
[ inputs.home-manager.nixosModules.home-manager ]
else
[ ]
) ++ modules;
};
in {
hulk = mkSystem inputs.nixpkgs "hulk";
hulk = mkSystem {
system = "x86_64-linux";
hostname = "hulk";
};
}

View File

@ -0,0 +1,77 @@
{ config, lib, ... }:
{
options.modules.fish = {
enable = lib.mkEnableOption "Fish integration";
enableDefaultAliases = lib.mkOption {
type = lib.types.bool;
default = true;
description = "Enable default aliases and abbreviations";
};
enableStarship = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Enable Starship prompt";
};
functions = lib.mkOption {
type = with lib.types; attrsOf str;
description = "Fish function definitions";
};
};
config = lib.mkIf config.modules.fish.enable {
programs.nix-index = {
enable = true;
enableFishIntegration = true;
};
programs.starship = lib.mkIf config.modules.fish.enableStarship {
enable = true;
enableFishIntegration = true;
};
programs.fish = {
enable = true;
interactiveShellInit = ''
set fish_greeting
cat ~/.cache/wal/sequences
'';
shellAliases = lib.mkIf config.modules.fish.enableDefaultAliases {
".." = "cd ..";
"..." = "cd ../..";
"...." = "cd ../../../";
"....." = "cd ../../../../";
"cp" = "cp -v";
"ddf" = "df -h";
"etc" = "erd -H";
"mkdir" = "mkdir -p";
"mv" = "mv -v";
"rm" = "rm -v";
"rr" = "rm -rf";
"neofetch" = "fastfetch";
};
shellAbbrs = lib.mkIf config.modules.fish.enableDefaultAliases {
gaa = "git add -A";
ga = "git add";
gbd = "git branch --delete";
gb = "git branch";
gc = "git commit";
gcm = "git commit -m";
gcob = "git checkout -b";
gco = "git checkout";
gd = "git diff";
gl = "git log";
gp = "git push";
gs = "git status";
};
functions = config.modules.fish.functions;
};
};
}

View File

@ -1,6 +1,5 @@
{ self, impurity, inputs, ... }: {
home-manager = {
verbose = true;
useGlobalPkgs = true;
useUserPackages = true;
backupFileExtension = "bak";

View File

@ -0,0 +1,32 @@
{
webcopy = ''
set -l domain (string trim $argv)
get --recursive \
--level 5 \
--no-clobber \
--page-requisites \
--adjust-extension \
--span-hosts \
--convert-links \
--domains $domain \
--no-parent \
$domain
'';
venv = ''
if [ -d .venv ]; then
source .venv/bin/activate.fish
else
python -m venv .venv
source .venv/bin/activate.fish
fi
'';
thunderbird = ''
if pgrep -x birdtray > /dev/null
birdtray -s
else
birdtray &
end
'';
}

View File

@ -1,77 +0,0 @@
{
imports = [
./starship.nix
./nix-index.nix
];
programs.fish = {
enable = true;
interactiveShellInit = ''
set fish_greeting
cat ~/.cache/wal/sequences
'';
shellAliases = {
".." = "cd ..";
"..." = "cd ../..";
"...." = "cd ../../../";
"....." = "cd ../../../../";
"cp" = "cp -v";
"ddf" = "df -h";
"etc" = "erd -H";
"mkdir" = "mkdir -p";
"mv" = "mv -v";
"rm" = "rm -v";
"rr" = "rm -rf";
"neofetch" = "fastfetch";
};
shellAbbrs = {
gaa = "git add -A";
ga = "git add";
gbd = "git branch --delete";
gb = "git branch";
gc = "git commit";
gcm = "git commit -m";
gcob = "git checkout -b";
gco = "git checkout";
gd = "git diff";
gl = "git log";
gp = "git push";
gs = "git status";
};
functions = {
webcopy = ''
function webcopy
set -l domain (string trim $argv)
wget --recursive \
--level 5 \
--no-clobber \
--page-requisites \
--adjust-extension \
--span-hosts \
--convert-links \
--domains $domain \
--no-parent \
$domain
end
'';
venv = ''
function venv
source .venv/bin/activate.fish
end
'';
thunderbird = ''
if pgrep -x birdtray > /dev/null
birdtray -s
else
birdtray &
end
'';
};
};
}

View File

@ -1,6 +0,0 @@
{
programs.nix-index = {
enable = true;
enableFishIntegration = true;
};
}

View File

@ -1,6 +0,0 @@
{
programs.starship = {
enable = true;
enableFishIntegration = true;
};
}

View File

@ -1,17 +1,6 @@
{ pkgs, inputs, ... }:
{
imports = [
../../modules/home-manager/darkman.nix
inputs.ags.homeManagerModules.default
];
modules.darkman = {
enable = true;
customLightModeScript = "$HOME/.config/hypr/scripts/random-wallpaper.sh";
customDarkModeScript = "$HOME/.config/hypr/scripts/random-wallpaper.sh";
};
home.packages = with pkgs; [
pywal pywalfox-native
@ -20,7 +9,6 @@
]))
inputs.nordvpn.packages.${system}.nordvpn
(pkgs.callPackage ../../derivations/ddt4all.nix {})
(birdtray.overrideAttrs (_: {
cmakeFlags = [ "-DOPT_THUNDERBIRD_CMDLINE=${thunderbird}/bin/thunderbird" ];

View File

@ -1,8 +1,24 @@
{ inputs, pkgs, ... }:
{
imports = [ ./fish ];
imports = [
../../modules/home-manager/darkman.nix
../../modules/home-manager/fish.nix
inputs.ags.homeManagerModules.default
];
modules.darkman = {
enable = true;
customLightModeScript = "$HOME/.config/hypr/scripts/random-wallpaper.sh";
customDarkModeScript = "$HOME/.config/hypr/scripts/random-wallpaper.sh";
};
modules.fish = {
enable = true;
enableStarship = true;
functions = import ./fish-functions.nix;
};
programs.pywal.enable = true;
programs.ags = {
enable = true;
@ -21,40 +37,8 @@
#advanced-scene-switcher
obs-tuna
obs-move-transition
droidcam-obs
waveform
wlrobs
];
};
services.darkman = {
enable = true;
darkModeScripts = {
theme = ''
${pkgs.dconf}/bin/dconf write\
/org/gnome/desktop/interface/color-scheme "'prefer-dark'"
'';
wallpaper = ''
$HOME/.config/hypr/scripts/random-wallpaper.sh
'';
pywalfox = "command -v pywalfox &>/dev/null && pywalfox dark && pywalfox update";
};
lightModeScripts = {
theme = ''
${pkgs.dconf}/bin/dconf write\
/org/gnome/desktop/interface/color-scheme "'prefer-light'"
'';
wallpaper = ''
$HOME/.config/hypr/scripts/random-wallpaper.sh
'';
pywalfox = "command -v pywalfox &>/dev/null && pywalfox light && pywalfox update";
};
settings.usegeoclue = true;
};
}

View File

@ -1,53 +0,0 @@
{ pkgs ? import <nixpkgs> {} }:
let
pythonWithPkgs = pkgs.python3.withPackages (ps: with ps; [
ps.pyqt5
ps.pyqtwebengine
ps.pyusb
ps.crcmod
ps.pyserial
]);
in
pkgs.mkShell {
name = "ddt4all-env";
buildInputs = [
pythonWithPkgs
pkgs.qt5.qtbase
pkgs.qt5.qttools
pkgs.git
pkgs.freetype
pkgs.libGL
pkgs.dbus
pkgs.xorg.libX11
pkgs.xorg.libXcomposite
pkgs.xorg.libXdamage
pkgs.xorg.libXfixes
pkgs.xorg.libXrender
pkgs.xorg.libXrandr
pkgs.xorg.libXtst
pkgs.glib
pkgs.expat
pkgs.fontconfig
];
nativeBuildInputs = [ pkgs.libsForQt5.qt5.wrapQtAppsHook ];
shellHook = ''wrapQtAppsHook'';
runScript = ''
cd $HOME/DDT4ALL
if [ ! -d ".venv" ]; then
python3 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
else
source .venv/bin/activate
fi
python3 main.py
'';
}

51
shells/ddt4all.nix Normal file
View File

@ -0,0 +1,51 @@
{ pkgs, ... }:
let
pythonWithPkgs = pkgs.python3.withPackages (ps: with ps; [
ps.pyqt5
ps.pyqtwebengine
ps.pyusb
ps.crcmod
ps.pyserial
]);
in pkgs.mkShell {
name = "ddt4all-env";
buildInputs = [
pythonWithPkgs
pkgs.qt5.qtbase
pkgs.qt5.qttools
pkgs.git
pkgs.freetype
pkgs.libGL
pkgs.dbus
pkgs.xorg.libX11
pkgs.xorg.libXcomposite
pkgs.xorg.libXdamage
pkgs.xorg.libXfixes
pkgs.xorg.libXrender
pkgs.xorg.libXrandr
pkgs.xorg.libXtst
pkgs.glib
pkgs.expat
pkgs.fontconfig
];
nativeBuildInputs = [ pkgs.libsForQt5.qt5.wrapQtAppsHook ];
shellHook = ''wrapQtAppsHook'';
runScript = ''
cd $HOME/DDT4ALL
if [ ! -d ".venv" ]; then
python3 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
else
source .venv/bin/activate
fi
python3 main.py
'';
}