This commit is contained in:
Tim Peters 2024-03-05 22:05:40 +01:00
commit d249a9dbb6
24 changed files with 579 additions and 0 deletions

56
configuration.nix Normal file
View File

@ -0,0 +1,56 @@
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running nixos-help).
{ config, pkgs, ... }:
let
dbus-sway-environment = pkgs.writeTextFile {
name = "dbus-sway-environment";
destination = "/bin/dbus-sway-environment";
executable = true;
text = ''
dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP DISPLAY SWAYSOCK
systemctl --user stop graphical-session.target
systemctl --user start sway-session.target
'';
};
configure-gtk = pkgs.writeTextFile {
name = "configure-gtk";
destination = "/bin/configure-gtk";
executable = true;
text = let
schema = pkgs.gsettings-desktop-schemas;
datadir = "${schema}/share/gsettings-schemas/${schema.name}";
in ''
export XDG_DATA_DIRS=${datadir}:$XDG_DATA_DIRS
gnome_schema=org.gnome.desktop.interface
${pkgs.glib}/bin/gsettings set $gnome_schema gtk-theme 'adw-gtk3-dark'
${pkgs.glib}/bin/gsettings set $gnome_schema color-scheme 'prefer-dark'
${pkgs.glib}/bin/gsettings set $gnome_schema icon-theme 'Adwaita'
'';
};
in
{
imports =
[
<home-manager/nixos>
./hardware-configuration.nix
./system
];
home-manager = {
useUserPackages = true;
useGlobalPkgs = true;
users.proto = import ./home;
};
nixpkgs.overlays =
[
(import ./overlays/pkgs.nix)
];
}

View File

@ -0,0 +1,42 @@
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:
{
imports =
[ (modulesPath + "/installer/scan/not-detected.nix")
];
boot.initrd.availableKernelModules = [ "xhci_pci" "ehci_pci" "ahci" "usb_storage" "sd_mod" "sdhci_pci" ];
boot.initrd.kernelModules = [ ];
boot.blacklistedKernelModules = [ "mei" "mei_me" ];
boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ];
fileSystems."/" =
{ device = "/dev/disk/by-uuid/1627403c-d3fb-460f-82d6-060002d63cf3";
fsType = "ext4";
};
fileSystems."/boot" =
{ device = "/dev/disk/by-uuid/3E48-4467";
fsType = "vfat";
};
swapDevices =
[ { device = "/dev/disk/by-uuid/9a5d629a-5c60-46fc-8643-889a50842527"; }
];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's
# still possible to use this option, but it's recommended to use it in conjunction
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true;
# networking.interfaces.eno0.useDHCP = lib.mkDefault true;
# networking.interfaces.wlp2s0.useDHCP = lib.mkDefault true;
# networking.interfaces.wwp0s29u1u4i6.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}

90
home-modules/matugen.nix Normal file
View File

@ -0,0 +1,90 @@
{ config, lib, pkgs, ... }:
let
cfg = config.programs.matugen;
sanitizedTemplates = builtins.mapAttrs (_: v: {
input_path = v.source;
output_path = builtins.replaceStrings ["$HOME"] ["~"] v.destination;
}) cfg.templates;
configFormat = pkgs.formats.toml {};
matugenConfig = configFormat.generate "matugen-config.toml" {
config = {};
templates = sanitizedTemplates;
};
themePackage = pkgs.runCommandLocal "matugen-themes-${cfg.variant}" {} ''
mkdir -p $out
cd $out
export HOME=$(pwd)
# Ok so the problem here is that /etc/ is not 'mounted' in the build environment.
# So yeah :D
${cfg.pkg}/bin/matugen \
image ${cfg.wallpaper} \
--config ${matugenConfig} \
--mode ${cfg.variant} \
--json hex \
--quiet \
> $out/theme.json
'';
colorsFile = builtins.fromJSON (builtins.readFile "${themePackage}/theme.json");
colors = colorsFile.colors.${cfg.variant};
in
{
options.programs.matugen = {
enable = lib.mkEnableOption "Matugen declarative theming";
wallpaper = lib.mkOption {
description = "Path to `wallpaper` that matugen will generate colors from";
type = lib.types.path;
};
variant = lib.mkOption {
description = "";
type = lib.types.enum [ "light" "dark" ];
default = "dark";
example = "light";
};
pkg = lib.mkPackageOption pkgs "matugen" {};
templates = lib.mkOption {
description = "Templates to generate output with.";
type = with lib.types;
attrsOf (submodule {
options = {
source = lib.mkOption {
type = path;
description = "Path to the source template";
example = "./gtk.css";
};
destination = lib.mkOption {
type = str;
description = "Destination path";
example = "gtk.css";
};
};
});
default = {};
};
theme.files = lib.mkOption {
description = "Generated theme files. Includes chosen variant only.";
type = lib.types.package;
readOnly = true;
default = themePackage;
};
theme.colors = lib.mkOption {
inherit (pkgs.formats.json {}) type;
description = "Generated theme colors";
readOnly = true;
default = colors;
};
};
}

BIN
home/background.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 MiB

115
home/default.nix Normal file
View File

@ -0,0 +1,115 @@
{ config, pkgs, ... }:
{
imports = [
../home-modules/matugen.nix
];
home.username = "proto";
home.homeDirectory = "/home/proto";
home.stateVersion = "23.11";
#programs.home-manager.enable = true;
programs.matugen = {
enable = true;
#wallpaper = "${pkgs.sway}/share/backgrounds/sway/Sway_Wallpaper_Blue_1920x1080.png";
wallpaper = ./background.jpg;
templates = {
"gtk" = {
source = ./gtk.css;
destination = "gtk.css";
};
};
};
xdg.configFile."gtk-3.0/gtk.css" = {
source = "${config.programs.matugen.theme.files}/gtk.css";
};
xdg.configFile."gtk-4.0/gtk.css" = {
source = "${config.programs.matugen.theme.files}/gtk.css";
};
programs.git = {
enable = true;
userName = "Tim Peters";
userEmail = "tim@protonomaly.nl";
};
home.pointerCursor = {
name = "Adwaita";
package = pkgs.gnome.adwaita-icon-theme;
gtk.enable = true;
size = 24;
};
gtk = {
enable = true;
theme = {
name = "adw-gtk3-dark";
package = pkgs.adw-gtk3;
};
iconTheme = {
name = "Adwaita";
package = pkgs.gnome.adwaita-icon-theme;
};
};
dconf.settings = {
"org/gnome/desktop/interface" = {
"color-scheme" = "prefer-dark";
};
};
programs.foot = {
enable = true;
settings = {
main = {
font = "IosevkaTerm Nerd Font:size=10";
};
};
};
wayland.windowManager.sway = {
enable = true;
wrapperFeatures.gtk = true;
config = {
modifier = "Mod4";
menu = "wofi --show=drun";
fonts = {
names = [ "Iosevka Nerd Font" ];
size = 10.0;
};
window.titlebar = false;
output = {
"*" = {
#bg = "${pkgs.sway}/share/backgrounds/sway/Sway_Wallpaper_Blue_1920x1080.png fill";
bg = "${./background.jpg} fill";
};
};
seat."*".hide_cursor = "500";
bars = [
{
position = "top";
statusCommand = "while date +'%Y-%m-%d %I:%M:%S %p'; do sleep 1; done";
fonts = {
names = [ "Iosevka Nerd Font" ];
size = 10.0;
};
colors = {
statusline = "#ffffff";
#background = "#323232";
background = config.programs.matugen.theme.colors.surface;
inactiveWorkspace = {
#background = "#32323200";
#border = "#32323200";
#text = "#5c5c5c";
background = "${config.programs.matugen.theme.colors.surface}80";
border = "${config.programs.matugen.theme.colors.surface}80";
text = config.programs.matugen.theme.colors.on_surface;
};
};
}
];
};
};
}

13
home/gtk.css Normal file
View File

@ -0,0 +1,13 @@
@define-color accent_color {{colors.primary_fixed_dim.default.hex}};
@define-color accent_fg_color {{colors.on_primary_fixed.default.hex}};
@define-color accent_bg_color {{colors.primary_fixed_dim.default.hex}};
@define-color window_bg_color {{colors.surface_dim.default.hex}};
@define-color window_fg_color {{colors.on_surface.default.hex}};
@define-color headerbar_bg_color {{colors.surface_dim.default.hex}};
@define-color headerbar_fg_color {{colors.on_surface.default.hex}};
@define-color popover_bg_color {{colors.surface_dim.default.hex}};
@define-color popover_fg_color {{colors.on_surface.default.hex}};
@define-color view_bg_color {{colors.surface.default.hex}};
@define-color view_fg_color {{colors.on_surface.default.hex}};
@define-color card_bg_color {{colors.surface.default.hex}};
@define-color card_fg_color {{colors.on_surface.default.hex}};

5
overlays/pkgs.nix Normal file
View File

@ -0,0 +1,5 @@
final: prev:
{
matugen = (final.callPackage ../pkgs/matugen.nix {});
}

22
pkgs/matugen.nix Normal file
View File

@ -0,0 +1,22 @@
{ lib, fetchFromGitHub, rustPlatform }:
rustPlatform.buildRustPackage rec {
pname = "matugen";
version = "v2.1.0";
src = fetchFromGitHub {
owner = "InioX";
repo = pname;
rev = version;
hash = "sha256-QxwHP7lKxmF62azsGssarQg6YDrugaUhK5JChKhlkRQ=";
};
cargoHash = "sha256-J5Bn3RZIiYoSKwNtOiFeA/Ng3/y9TMJ7eNXqXtwxvOA=";
meta = with lib; {
description = "";
homepage = "https://github.com/InioX/matugen";
license = licenses.gpl2;
maintainers = [];
};
}

BIN
system/.default.nix.swp Normal file

Binary file not shown.

7
system/core/boot.nix Normal file
View File

@ -0,0 +1,7 @@
{ config, pkgs, ... }:
{
# Bootloader.
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
}

43
system/core/default.nix Normal file
View File

@ -0,0 +1,43 @@
{ config, pkgs, ... }:
{
imports =
[
./boot.nix
./nixpkgs.nix
./users.nix
];
security.rtkit.enable = true;
# Fix xdg-portals issue https://github.com/NixOS/nixpkgs/issues/189851
systemd.user.extraConfig = ''
DefaultEnvironment = "PATH=/run/wrappers/bin:/etc/profiles/per-user/%u/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin"
'';
# Set your time zone.
time.timeZone = "Europe/Oslo";
# Select internationalisation properties.
i18n.defaultLocale = "en_US.UTF-8";
i18n.extraLocaleSettings = {
LC_ADDRESS = "en_GB.UTF-8";
LC_IDENTIFICATION = "en_GB.UTF-8";
LC_MEASUREMENT = "en_GB.UTF-8";
LC_MONETARY = "en_GB.UTF-8";
LC_NAME = "en_GB.UTF-8";
LC_NUMERIC = "en_GB.UTF-8";
LC_PAPER = "en_GB.UTF-8";
LC_TELEPHONE = "en_GB.UTF-8";
LC_TIME = "en_GB.UTF-8";
};
# This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions
# on your system were taken. Its perfectly fine and recommended to leave
# this value at the release version of the first install of this system.
# Before changing this value read the documentation for this option
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
system.stateVersion = "23.11"; # Did you read the comment?
}

6
system/core/nixpkgs.nix Normal file
View File

@ -0,0 +1,6 @@
{ config, pkgs, ... }:
{
# Allow unfree packages
nixpkgs.config.allowUnfree = true;
}

11
system/core/users.nix Normal file
View File

@ -0,0 +1,11 @@
{ config, pkgs, ... }:
{
# Define a user account. Don't forget to set a password with passwd.
users.users.proto = {
isNormalUser = true;
description = "Tim Peters";
extraGroups = [ "networkmanager" "wheel" "input" ];
packages = with pkgs; [ ];
};
}

39
system/default.nix Normal file
View File

@ -0,0 +1,39 @@
{ config, pkgs, ... }:
{
imports =
[
./core
./services
./programs
./network.nix
./hardware.nix
./xdg.nix
./qt.nix
./fonts.nix
];
environment.systemPackages = with pkgs; [
vim
firefox
rustup
git
htop
openssh
kitty
waybar
wofi
eww-wayland
rofi-wayland
#dbus-sway-environment
#configure-gtk
cinnamon.nemo
gnome.nautilus
matugen
];
}

9
system/fonts.nix Normal file
View File

@ -0,0 +1,9 @@
{ config, pkgs, ... }:
{
fonts.fontDir.enable = true;
fonts.packages = with pkgs; [
noto-fonts
(nerdfonts.override {fonts = ["JetBrainsMono" "Iosevka" "IosevkaTerm" ];})
];
}

6
system/hardware.nix Normal file
View File

@ -0,0 +1,6 @@
{ config, pkgs, ... }:
{
hardware.opengl.enable = true;
hardware.bluetooth.enable = true;
}

11
system/network.nix Normal file
View File

@ -0,0 +1,11 @@
{ config, pkgs, ... }:
{
systemd.network.wait-online.enable = false;
networking.hostName = "bleep"; # Define your hostname.
# networking.wireless.enable = true; # Enables wireless support via wpa_supplicant.
# Enable networking
networking.networkmanager.enable = true;
}

View File

@ -0,0 +1,10 @@
{ config, pkgs, ... }:
{
programs.dconf.enable = true;
programs.sway = {
enable = true;
wrapperFeatures.gtk = true;
};
}

9
system/qt.nix Normal file
View File

@ -0,0 +1,9 @@
{ config, pkgs, ... }:
{
qt = {
enable = true;
platformTheme = "gtk2";
style = "gtk2";
};
}

View File

@ -0,0 +1,12 @@
{ config, pkgs, ... }:
{
imports =
[
./greetd.nix
./pipewire.nix
./polkit.nix
];
services.fstrim.enable = true;
}

View File

@ -0,0 +1,27 @@
{ config, pkgs, ... }:
let
greetdSwayConfig = pkgs.writeText "greetd-sway-config" ''
exec "${pkgs.greetd.gtkgreet}/bin/gtkgreet -l; swaymsg exit"
bindsym Mod4+Shift+e exec swaynag \
-t warning \
-m 'What do you want to do?' \
-b 'Poweroff' 'systemctl poweroff' \
-b 'Reboot' 'systemctl reboot'
'';
in
{
services.greetd = {
enable = true;
settings = {
default_session = {
command = "${pkgs.sway}/bin/sway --config ${greetdSwayConfig}";
};
};
};
environment.etc."greetd/environments".text = ''
sway
'';
}

View File

@ -0,0 +1,14 @@
{ config, pkgs, ... }:
{
# Enable sound with pipewire.
sound.enable = true;
hardware.pulseaudio.enable = false;
services.pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
};
}

View File

@ -0,0 +1,19 @@
{ config, pkgs, ... }:
{
security.polkit.enable = true;
systemd.user.services.polkit-gnome-authentication-agent-1 = {
description = "polkit-gnome-authentication-agent-1";
wantedBy = ["graphical-session.target"];
wants = ["graphical-session.target"];
after = ["graphical-session.target"];
serviceConfig = {
Type = "simple";
ExecStart = "${pkgs.polkit_gnome}/libexec/polkit-gnome-authentication-agent-1";
Restart = "on-failure";
RestartSec = 1;
TimeoutStopSec = 10;
};
};
}

13
system/xdg.nix Normal file
View File

@ -0,0 +1,13 @@
{ config, pkgs, ... }:
{
xdg = {
portal = {
enable = true;
xdgOpenUsePortal = true;
extraPortals = with pkgs; [
xdg-desktop-portal-gtk
];
};
};
}