commit d249a9dbb6c3094406b5cee236895a631f0bbb53 Author: Tim Peters Date: Tue Mar 5 22:05:40 2024 +0100 Gen 1 diff --git a/configuration.nix b/configuration.nix new file mode 100644 index 0000000..820b047 --- /dev/null +++ b/configuration.nix @@ -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 = + [ + + ./hardware-configuration.nix + ./system + ]; + + home-manager = { + useUserPackages = true; + useGlobalPkgs = true; + users.proto = import ./home; + }; + + nixpkgs.overlays = + [ + (import ./overlays/pkgs.nix) + ]; +} diff --git a/hardware-configuration.nix b/hardware-configuration.nix new file mode 100644 index 0000000..86c9817 --- /dev/null +++ b/hardware-configuration.nix @@ -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..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; +} diff --git a/home-modules/matugen.nix b/home-modules/matugen.nix new file mode 100644 index 0000000..a3b1d64 --- /dev/null +++ b/home-modules/matugen.nix @@ -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; + }; + }; +} diff --git a/home/background.jpg b/home/background.jpg new file mode 100644 index 0000000..1efe12a Binary files /dev/null and b/home/background.jpg differ diff --git a/home/default.nix b/home/default.nix new file mode 100644 index 0000000..b50e04b --- /dev/null +++ b/home/default.nix @@ -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; + }; + }; + } + ]; + }; + }; +} diff --git a/home/gtk.css b/home/gtk.css new file mode 100644 index 0000000..dc1872d --- /dev/null +++ b/home/gtk.css @@ -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}}; diff --git a/overlays/pkgs.nix b/overlays/pkgs.nix new file mode 100644 index 0000000..a09fe24 --- /dev/null +++ b/overlays/pkgs.nix @@ -0,0 +1,5 @@ +final: prev: + +{ + matugen = (final.callPackage ../pkgs/matugen.nix {}); +} diff --git a/pkgs/matugen.nix b/pkgs/matugen.nix new file mode 100644 index 0000000..1665ae0 --- /dev/null +++ b/pkgs/matugen.nix @@ -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 = []; + }; +} diff --git a/system/.default.nix.swp b/system/.default.nix.swp new file mode 100644 index 0000000..3543f7b Binary files /dev/null and b/system/.default.nix.swp differ diff --git a/system/core/boot.nix b/system/core/boot.nix new file mode 100644 index 0000000..438eb08 --- /dev/null +++ b/system/core/boot.nix @@ -0,0 +1,7 @@ +{ config, pkgs, ... }: + +{ + # Bootloader. + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; +} diff --git a/system/core/default.nix b/system/core/default.nix new file mode 100644 index 0000000..0d24524 --- /dev/null +++ b/system/core/default.nix @@ -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. It‘s 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? +} diff --git a/system/core/nixpkgs.nix b/system/core/nixpkgs.nix new file mode 100644 index 0000000..d1aaf53 --- /dev/null +++ b/system/core/nixpkgs.nix @@ -0,0 +1,6 @@ +{ config, pkgs, ... }: + +{ + # Allow unfree packages + nixpkgs.config.allowUnfree = true; +} diff --git a/system/core/users.nix b/system/core/users.nix new file mode 100644 index 0000000..ffac4e4 --- /dev/null +++ b/system/core/users.nix @@ -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; [ ]; + }; +} diff --git a/system/default.nix b/system/default.nix new file mode 100644 index 0000000..ae16db5 --- /dev/null +++ b/system/default.nix @@ -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 + ]; +} diff --git a/system/fonts.nix b/system/fonts.nix new file mode 100644 index 0000000..38d2818 --- /dev/null +++ b/system/fonts.nix @@ -0,0 +1,9 @@ +{ config, pkgs, ... }: + +{ + fonts.fontDir.enable = true; + fonts.packages = with pkgs; [ + noto-fonts + (nerdfonts.override {fonts = ["JetBrainsMono" "Iosevka" "IosevkaTerm" ];}) + ]; +} diff --git a/system/hardware.nix b/system/hardware.nix new file mode 100644 index 0000000..491f48f --- /dev/null +++ b/system/hardware.nix @@ -0,0 +1,6 @@ +{ config, pkgs, ... }: + +{ + hardware.opengl.enable = true; + hardware.bluetooth.enable = true; +} diff --git a/system/network.nix b/system/network.nix new file mode 100644 index 0000000..0dfcc5b --- /dev/null +++ b/system/network.nix @@ -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; +} diff --git a/system/programs/default.nix b/system/programs/default.nix new file mode 100644 index 0000000..ee8a223 --- /dev/null +++ b/system/programs/default.nix @@ -0,0 +1,10 @@ +{ config, pkgs, ... }: + +{ + programs.dconf.enable = true; + + programs.sway = { + enable = true; + wrapperFeatures.gtk = true; + }; +} diff --git a/system/qt.nix b/system/qt.nix new file mode 100644 index 0000000..b1bdb26 --- /dev/null +++ b/system/qt.nix @@ -0,0 +1,9 @@ +{ config, pkgs, ... }: + +{ + qt = { + enable = true; + platformTheme = "gtk2"; + style = "gtk2"; + }; +} diff --git a/system/services/default.nix b/system/services/default.nix new file mode 100644 index 0000000..9d4c852 --- /dev/null +++ b/system/services/default.nix @@ -0,0 +1,12 @@ +{ config, pkgs, ... }: + +{ + imports = + [ + ./greetd.nix + ./pipewire.nix + ./polkit.nix + ]; + + services.fstrim.enable = true; +} diff --git a/system/services/greetd.nix b/system/services/greetd.nix new file mode 100644 index 0000000..20643cb --- /dev/null +++ b/system/services/greetd.nix @@ -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 + ''; +} diff --git a/system/services/pipewire.nix b/system/services/pipewire.nix new file mode 100644 index 0000000..3649707 --- /dev/null +++ b/system/services/pipewire.nix @@ -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; + }; +} diff --git a/system/services/polkit.nix b/system/services/polkit.nix new file mode 100644 index 0000000..84d5eb8 --- /dev/null +++ b/system/services/polkit.nix @@ -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; + }; + }; +} diff --git a/system/xdg.nix b/system/xdg.nix new file mode 100644 index 0000000..e435f98 --- /dev/null +++ b/system/xdg.nix @@ -0,0 +1,13 @@ +{ config, pkgs, ... }: + +{ + xdg = { + portal = { + enable = true; + xdgOpenUsePortal = true; + extraPortals = with pkgs; [ + xdg-desktop-portal-gtk + ]; + }; + }; +}