treewide: use a more proper structure

This commit is contained in:
EdenQwQ 2025-03-21 19:01:18 +08:00
parent 31145354fb
commit 7f7f5df90d
23 changed files with 282 additions and 293 deletions

View file

@ -2,7 +2,6 @@
imports = [
./colorScheme
./wallpaper
./monitors.nix
./swhkd.nix
./addFlags.nix
];

View file

@ -3,7 +3,7 @@ let
colors = config.lib.stylix.colors.withHashtag;
in
{
home.packages = with (pkgs.callPackage ../../../pkgs/R.nix { }); [
home.packages = with pkgs; [
(config.lib.misc.addFlags
"--enable-features=UseOzonePlatform --ozone-platform=wayland --use-gl=angle --wayland-text-input-version=3"
"rstudio"

View file

@ -1,7 +1,7 @@
{ pkgs, lib, ... }:
{
home.packages = [
(pkgs.callPackage ../../../pkgs/fonts/kose.nix { })
(pkgs.callPackage ../../../pkgs/fonts/hugmetight.nix { })
pkgs.kose-font
pkgs.hugmetight-font
];
}

View file

@ -3,14 +3,10 @@
config,
...
}:
let
edenfetch = pkgs.callPackage ../../../pkgs/edenfetch.nix { };
in
{
home.packages = with pkgs; [
cmatrix
cbonsai
edenfetch
];
programs.fastfetch.enable = true;
xdg.configFile."fastfetch/config.jsonc".source = ./fastfetch.jsonc;

View file

@ -1,67 +1,18 @@
{ config, lib, ... }:
let
matugenOptions = lib.types.submodule {
options = {
image = lib.mkOption {
type = lib.types.either lib.types.str lib.types.path;
description = "Path to the image";
};
scheme = lib.mkOption {
type = lib.types.str;
description = "The material you scheme to use";
default = "scheme-tonal-spot";
};
};
};
colorScheme = lib.types.submodule {
options = {
name = lib.mkOption {
type = lib.types.str;
description = "Name of the color scheme";
};
isDefault = lib.mkOption {
type = lib.types.bool;
description = "Whether the color scheme is the default";
default = false;
};
polarity = lib.mkOption {
type = lib.types.enum [
"dark"
"light"
];
description = "Polarity of the color scheme (dark or light)";
default = "dark";
};
matugen = lib.mkOption {
type = lib.types.nullOr matugenOptions;
description = "Matugen options";
default = null;
};
};
};
in
{
options.colorSchemes = lib.mkOption {
type = lib.types.listOf (lib.types.either colorScheme lib.types.str);
description = "List of colorschemes";
};
config =
with config.lib.colorScheme;
let
colorSchemes = config.colorSchemes |> map convertColorScheme;
in
colorSchemes = [
{
stylix = {
enable = true;
inherit (builtins.filter (c: c.isDefault) colorSchemes |> builtins.head |> buildColorScheme)
base16Scheme
polarity
;
name = "gruvbox-material-dark-soft";
isDefault = true;
}
"everforest"
"nord"
"petrichor-downpour"
{
name = "green-blue-flowers-dark";
matugen = {
image = "green-blue-flowers.jpg";
scheme = "scheme-expressive";
};
specialisation =
builtins.filter (c: !c.isDefault) colorSchemes |> map buildSpecialisation |> builtins.listToAttrs;
};
}
];
}

View file

@ -1,42 +1,64 @@
{ config, lib, ... }:
with config.lib.wallpapers;
let
wallpaper = lib.types.submodule {
options = {
name = lib.mkOption {
type = lib.types.str;
description = "Name of the wallpaper";
};
url = lib.mkOption {
type = lib.types.str;
description = "URL of the wallpaper";
};
sha256 = lib.mkOption {
type = lib.types.str;
description = "SHA256 of the wallpaper";
};
convertMethod = lib.mkOption {
type = lib.types.str;
description = "Method to convert the wallpaper (gonord, lutgen, none)";
default = "lutgen";
};
};
};
in
{
options.wallpapers = lib.mkOption {
type = lib.types.listOf wallpaper;
description = "List of wallpapers";
};
config =
let
wallpapers = map getWallpaper config.wallpapers;
generatedWallpapers = map generateWallpaper wallpapers;
normalWallpapers = map setWallpaper generatedWallpapers |> builtins.listToAttrs;
blurredWallpapers = map blurWallpaper generatedWallpapers |> builtins.listToAttrs;
in
wallpapers = [
{
home.file = normalWallpapers // blurredWallpapers;
};
name = "mygo-watch-tv.png";
url = "https://i.imgur.com/FSneBN2.jpg";
sha256 = "1pznrjx6rb8qm947q63dzkrmv188h3nrcp8cdmd7hs5gs30azfww";
convertMethod = "gonord";
}
{
name = "frieren-butterflies.jpg";
url = "https://i.imgur.com/H1noDhu.jpg";
sha256 = "0vypn9sxarv2gw42hs2haasyvzqyp02s6vaqygp9xbg59m0x2l73";
convertMethod = "lutgen";
}
{
name = "frieren-fire.jpg";
url = "https://i.imgur.com/c3CWmia.jpg";
sha256 = "0lgqwjl6jd1y84cz368s4sq0krzg67znqxirzapqxqvfdpn9rwbw";
convertMethod = "lutgen";
}
{
name = "anon-soyo.jpg";
url = "https://i.imgur.com/koPV5sz.png";
sha256 = "031s3v8fp5q2dm95wra898jq9l4i49wlwf97iah6bjqi5ihaxs2x";
convertMethod = "gonord";
}
{
name = "mygo-train.jpg";
url = "https://i.imgur.com/OzR8c12.jpg";
sha256 = "0fnwasnr19wfyhxa5yq7g3315d1641602x7fg8sv1qv95dlj55w2";
convertMethod = "gonord";
}
{
name = "green-blue-flowers.jpg";
url = "https://i.imgur.com/Kvjqksw.jpg";
sha256 = "1la4g50sxc940j9vcf7440l73ycx05z63dmpfq8xn0b746hzmnkq";
convertMethod = "gonord";
}
{
name = "bangqiaoyan-girl-sky.jpg";
url = "https://i.imgur.com/qJ3ta1b.jpg";
sha256 = "1chzklk6j893fdxhp0jhjwgwyhg3p6hjrgrrr5fw8gkllx91sx5w";
convertMethod = "gonord";
}
{
name = "morncolour-pink-landscape.png";
url = "https://i.imgur.com/BBzCYYQ.png";
sha256 = "14kjc7zipbwvswjbkzqk4781as6pn31naq26nxknzhmr4z5rhzci";
convertMethod = "gonord";
}
{
name = "jiaocha-girl-sea.jpg";
url = "https://i.imgur.com/LBowln5.jpeg";
sha256 = "0agpr2z7v6q77ypgfsl6b57gac7ncrgf1fh0b5g7g0a53mzib5hm";
convertMethod = "gonord";
}
{
name = "muji-monochrome.jpg";
url = "https://i.imgur.com/F2h7rsD.jpg";
sha256 = "02q0wd2xpyjfiifmrsf6sg1ja3zlb9514g98w156f7jdpw2c9ppb";
convertMethod = "gonord";
}
];
}

View file

@ -6,17 +6,15 @@
}:
let
sharedOSModules = [
../overlays
../os
../nix
inputs.stylix.nixosModules.stylix
inputs.niri.nixosModules.niri
];
sharedHomeModules = [
../overlays
../home
../nix/nixpkgs.nix
../sharedConfig.nix
inputs.nur.modules.homeManager.default
inputs.stylix.homeManagerModules.stylix
inputs.niri.homeModules.niri
@ -24,7 +22,7 @@ let
inputs.agenix.homeManagerModules.default
../secrets/age.nix
inputs.distrobox4nix.homeManagerModule
];
] ++ (builtins.attrValues self.homeManagerModules);
in
{
flake =
@ -33,6 +31,10 @@ in
user = "eden";
in
{
overlays = import ../overlays { inherit inputs; };
homeManagerModules = import ../modules/home-manager;
nixosConfigurations.${host} = nixpkgs.lib.nixosSystem {
specialArgs = {
inherit
@ -47,6 +49,7 @@ in
./inspiron/os.nix
] ++ sharedOSModules;
};
homeConfigurations."${user}@${host}" = inputs.home-manager.lib.homeManagerConfiguration {
pkgs = nixpkgs.legacyPackages."x86_64-linux";
extraSpecialArgs = {

View file

@ -0,0 +1,69 @@
{ config, lib, ... }:
with lib;
with types;
let
matugenOptions = submodule {
options = {
image = mkOption {
type = either str path;
description = "Path to the image";
};
scheme = mkOption {
type = str;
description = "The material you scheme to use";
default = "scheme-tonal-spot";
};
};
};
colorScheme = submodule {
options = {
name = mkOption {
type = str;
description = "Name of the color scheme";
};
isDefault = mkOption {
type = bool;
description = "Whether the color scheme is the default";
default = false;
};
polarity = mkOption {
type = enum [
"dark"
"light"
];
description = "Polarity of the color scheme (dark or light)";
default = "dark";
};
matugen = mkOption {
type = nullOr matugenOptions;
description = "Matugen options";
default = null;
};
};
};
in
{
options.colorSchemes = mkOption {
type = listOf (either colorScheme str);
description = "List of colorschemes";
};
config =
with config.lib.colorScheme;
let
colorSchemes = config.colorSchemes |> map convertColorScheme;
in
{
stylix = {
enable = true;
inherit (builtins.filter (c: c.isDefault) colorSchemes |> builtins.head |> buildColorScheme)
base16Scheme
polarity
;
};
specialisation =
builtins.filter (c: !c.isDefault) colorSchemes |> map buildSpecialisation |> builtins.listToAttrs;
};
}

View file

@ -0,0 +1,5 @@
{
monitors = import ./monitors.nix;
colorscheme = import ./colorscheme.nix;
wallpapers = import ./wallpaper.nix;
}

View file

@ -1,51 +1,53 @@
{ lib, config, ... }:
with lib;
with types;
let
monitor = lib.types.submodule {
monitor = submodule {
options = {
isMain = lib.mkOption {
type = lib.types.bool;
isMain = mkOption {
type = bool;
description = "Whether the monitor is the main one";
default = false;
};
scale = lib.mkOption {
type = lib.types.float;
scale = mkOption {
type = float;
description = "The scale of the monitor";
default = 1.0;
};
mode = lib.mkOption {
type = lib.types.submodule {
mode = mkOption {
type = submodule {
options = {
width = lib.mkOption {
type = lib.types.int;
width = mkOption {
type = int;
description = "The width of the monitor";
};
height = lib.mkOption {
type = lib.types.int;
height = mkOption {
type = int;
description = "The height of the monitor";
};
refresh = lib.mkOption {
type = lib.types.float;
refresh = mkOption {
type = float;
description = "The refresh rate of the monitor";
};
};
};
};
position = lib.mkOption {
type = lib.types.submodule {
position = mkOption {
type = submodule {
options = {
x = lib.mkOption {
type = lib.types.int;
x = mkOption {
type = int;
description = "The x position of the monitor";
};
y = lib.mkOption {
type = lib.types.int;
y = mkOption {
type = int;
description = "The y position of the monitor";
};
};
};
};
rotation = lib.mkOption {
type = lib.types.int;
rotation = mkOption {
type = int;
description = "The rotation of the monitor";
};
};
@ -53,8 +55,8 @@ let
in
{
options.monitors = lib.mkOption {
type = lib.types.attrsOf monitor;
options.monitors = mkOption {
type = attrsOf monitor;
};
config.lib.monitors.mainMonitorName =

View file

@ -0,0 +1,44 @@
{ config, lib, ... }:
with lib;
with types;
with config.lib.wallpapers;
let
wallpaper = submodule {
options = {
name = mkOption {
type = str;
description = "Name of the wallpaper";
};
url = mkOption {
type = str;
description = "URL of the wallpaper";
};
sha256 = mkOption {
type = str;
description = "SHA256 of the wallpaper";
};
convertMethod = mkOption {
type = str;
description = "Method to convert the wallpaper (gonord, lutgen, none)";
default = "lutgen";
};
};
};
in
{
options.wallpapers = mkOption {
type = listOf wallpaper;
description = "List of wallpapers";
};
config =
let
wallpapers = map getWallpaper config.wallpapers;
generatedWallpapers = map generateWallpaper wallpapers;
normalWallpapers = map setWallpaper generatedWallpapers |> builtins.listToAttrs;
blurredWallpapers = map blurWallpaper generatedWallpapers |> builtins.listToAttrs;
in
{
home.file = normalWallpapers // blurredWallpapers;
};
}

View file

@ -1,10 +1,14 @@
{ self, ... }:
{
nixpkgs.config = {
allowUnfree = true;
permittedInsecurePackages = [
"openssl-1.1.1w"
"electron-19.1.9"
];
allowUnsupportedSystem = true;
nixpkgs = {
config = {
allowUnfree = true;
permittedInsecurePackages = [
"openssl-1.1.1w"
"electron-19.1.9"
];
allowUnsupportedSystem = true;
};
overlays = builtins.attrValues self.overlays;
};
}

View file

@ -1,9 +1,6 @@
{ pkgs, ... }:
let
swhkd = pkgs.callPackage ../../pkgs/swhkd.nix { };
in
{
environment.systemPackages = [
swhkd
pkgs.swhkd
];
}

View file

@ -1,28 +0,0 @@
{ pkgs, ... }:
let
customColorSchemes = pkgs.stdenvNoCC.mkDerivation {
name = "customColorSchemes";
src = ./colorSchemes;
installPhase = ''
mkdir -p $out/share/themes
cp *.yaml $out/share/themes
'';
};
in
{
nixpkgs.overlays = [
(final: prev: {
base16-schemes = prev.base16-schemes.overrideAttrs (oldAttrs: {
installPhase = ''
runHook preInstall
mkdir -p $out/share/themes/
install base16/*.yaml $out/share/themes/
install ${customColorSchemes}/share/themes/*.yaml $out/share/themes/
runHook postInstall
'';
});
})
];
}

View file

@ -1,10 +1,25 @@
{ inputs, ... }:
{
imports = [
./qutebrowser.nix
./customColorSchemes
];
nixpkgs.overlays = [
inputs.niri.overlays.niri
];
additions =
final: prev:
import ../pkgs {
pkgs = final;
};
modifications = final: prev: {
qutebrowser = prev.qutebrowser.override { enableWideVine = true; };
base16-schemes = prev.base16-schemes.overrideAttrs (oldAttrs: {
installPhase = ''
runHook preInstall
mkdir -p $out/share/themes/
install base16/*.yaml $out/share/themes/
install ${final.custom-colorschemes}/share/themes/*.yaml $out/share/themes/
runHook postInstall
'';
});
};
inherit (inputs.niri.overlays) niri;
}

View file

@ -1,5 +0,0 @@
{
nixpkgs.overlays = [
(_: prev: { qutebrowser = prev.qutebrowser.override { enableWideVine = true; }; })
];
}

View file

@ -0,0 +1,9 @@
{ stdenvNoCC, ... }:
stdenvNoCC.mkDerivation {
name = "custom-colorschemes";
src = ./colorSchemes;
installPhase = ''
mkdir -p $out/share/themes
cp *.yaml $out/share/themes
'';
}

10
pkgs/default.nix Normal file
View file

@ -0,0 +1,10 @@
{ pkgs, ... }:
{
inherit (pkgs.callPackage ./R.nix { }) myR;
inherit (pkgs.callPackage ./R.nix { }) myRstudio;
zju-connect = pkgs.callPackage ./zju-connect.nix { };
swhkd = pkgs.callPackage ./swhkd.nix { };
kose-font = pkgs.callPackage ./fonts/kose.nix { };
hugmetight-font = pkgs.callPackage ./fonts/hugmetight.nix { };
custom-colorschemes = pkgs.callPackage ./customColorSchemes { };
}

View file

@ -1,23 +0,0 @@
{
lib,
fetchFromGitHub,
rustPlatform,
}:
rustPlatform.buildRustPackage {
pname = "edenfetch";
version = "0.1.0";
src = fetchFromGitHub {
owner = "EdenQwQ";
repo = "edenfetch";
rev = "ae6cc1207990e35288ed4a58caa21564bf1df9c3";
hash = "sha256-ipdz6tIB7BF43lwk+KN+9orW0FLt7HJsCZuN2wbe6Is=";
};
useFetchCargoVendor = true;
cargoHash = "sha256-t+tHvhTMwQwmozit6vcqE9iRZElaG4wJdzg79gcBJNY=";
meta = {
description = "edenfetch is a minimal fetch program written in Rust.";
homepage = "https://github.com/EdenQwQ/edenfetch";
mainProgram = "edenfetch";
maintainers = with lib.maintainers; [ EdenQwQ ];
};
}

View file

@ -4,7 +4,7 @@
pkgs,
}:
stdenvNoCC.mkDerivation {
pname = "kose-font";
pname = "hugmetight-font";
version = "2025-03-01";
src = pkgs.fetchzip {

View file

@ -1,81 +0,0 @@
{
colorSchemes = [
{
name = "gruvbox-material-dark-soft";
isDefault = true;
}
"everforest"
"nord"
"petrichor-downpour"
{
name = "green-blue-flowers-dark";
matugen = {
image = "green-blue-flowers.jpg";
scheme = "scheme-expressive";
};
}
];
wallpapers = [
{
name = "mygo-watch-tv.png";
url = "https://i.imgur.com/FSneBN2.jpg";
sha256 = "1pznrjx6rb8qm947q63dzkrmv188h3nrcp8cdmd7hs5gs30azfww";
convertMethod = "gonord";
}
{
name = "frieren-butterflies.jpg";
url = "https://i.imgur.com/H1noDhu.jpg";
sha256 = "0vypn9sxarv2gw42hs2haasyvzqyp02s6vaqygp9xbg59m0x2l73";
convertMethod = "lutgen";
}
{
name = "frieren-fire.jpg";
url = "https://i.imgur.com/c3CWmia.jpg";
sha256 = "0lgqwjl6jd1y84cz368s4sq0krzg67znqxirzapqxqvfdpn9rwbw";
convertMethod = "lutgen";
}
{
name = "anon-soyo.jpg";
url = "https://i.imgur.com/koPV5sz.png";
sha256 = "031s3v8fp5q2dm95wra898jq9l4i49wlwf97iah6bjqi5ihaxs2x";
convertMethod = "gonord";
}
{
name = "mygo-train.jpg";
url = "https://i.imgur.com/OzR8c12.jpg";
sha256 = "0fnwasnr19wfyhxa5yq7g3315d1641602x7fg8sv1qv95dlj55w2";
convertMethod = "gonord";
}
{
name = "green-blue-flowers.jpg";
url = "https://i.imgur.com/Kvjqksw.jpg";
sha256 = "1la4g50sxc940j9vcf7440l73ycx05z63dmpfq8xn0b746hzmnkq";
convertMethod = "gonord";
}
{
name = "bangqiaoyan-girl-sky.jpg";
url = "https://i.imgur.com/qJ3ta1b.jpg";
sha256 = "1chzklk6j893fdxhp0jhjwgwyhg3p6hjrgrrr5fw8gkllx91sx5w";
convertMethod = "gonord";
}
{
name = "morncolour-pink-landscape.png";
url = "https://i.imgur.com/BBzCYYQ.png";
sha256 = "14kjc7zipbwvswjbkzqk4781as6pn31naq26nxknzhmr4z5rhzci";
convertMethod = "gonord";
}
{
name = "jiaocha-girl-sea.jpg";
url = "https://i.imgur.com/LBowln5.jpeg";
sha256 = "0agpr2z7v6q77ypgfsl6b57gac7ncrgf1fh0b5g7g0a53mzib5hm";
convertMethod = "gonord";
}
{
name = "muji-monochrome.jpg";
url = "https://i.imgur.com/F2h7rsD.jpg";
sha256 = "02q0wd2xpyjfiifmrsf6sg1ja3zlb9514g98w156f7jdpw2c9ppb";
convertMethod = "gonord";
}
];
}