From 1c432072118a55120907ab6ba4a4dd6a276c1a21 Mon Sep 17 00:00:00 2001 From: EsVagy42 Date: Tue, 15 Jul 2025 16:55:59 +0200 Subject: [PATCH] Made productive a specialisation, fixes #15 and #21 --- commit_text | 2 +- configuration.nix | 326 ++++++++++++++++++++++++++-------------------- flake.nix | 61 +++++---- result | 1 + 4 files changed, 213 insertions(+), 177 deletions(-) create mode 120000 result diff --git a/commit_text b/commit_text index 499daba..d7f1faf 100644 --- a/commit_text +++ b/commit_text @@ -1 +1 @@ -Updated nixvim in flake +Made productive a specialisation diff --git a/configuration.nix b/configuration.nix index 3fbd352..6a8741e 100644 --- a/configuration.nix +++ b/configuration.nix @@ -2,11 +2,126 @@ # your system. Help is available in the configuration.nix(5) man page # and in the NixOS manual (accessible by running ‘nixos-help’). -{ config, pkgs, lib, ... }: +{ + config, + pkgs, + lib, + ... +}: +let + basePackages = with pkgs; [ + # vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default. + # wget + kdePackages.krecorder + kdePackages.kweather + kdePackages.kcharselect + kdePackages.filelight + kdePackages.kcalc + kdePackages.kclock + kdePackages.kholidays + kdePackages.akonadi-calendar + kdePackages.libkdepim + kdePackages.kdepim-addons + kdePackages.kdepim-runtime + kdePackages.kcontacts + libqalculate + qalculate-qt + maliit-keyboard + + librewolf + kdePackages.plasma-browser-integration + kdePackages.xdg-desktop-portal-kde + + kdePackages.zanshin + kdePackages.korganizer + kdePackages.merkuro + kdePackages.francis + + wl-clipboard + lldb + kdePackages.kompare + kdePackages.kdevelop + kdePackages.kcachegrind + gcc + gdb + clang-tools + bash-language-server + nixd + nixfmt-rfc-style + marksman + kdePackages.markdownpart + lua + lua-language-server + cppcheck + nixos-shell + + kdePackages.qtwebengine + kdePackages.qtlocation + kdePackages.ksystemstats # needed for the resource widgets + aspell # needed for spell checking + aspellDicts.en + aspellDicts.hu + kdePackages.qtmultimedia + kdePackages.karousel + ( + with pkgs; + import ./kwin4_effect_geometry_change/kwin4_effect_geometry_change.nix { + inherit lib; + inherit stdenv; + inherit fetchFromGitHub; + kpackage = kdePackages.kpackage; + kwin = kdePackages.kwin; + inherit nodejs; + } + ) + + gimp + inkscape + kdePackages.kdenlive + + libreoffice + pandoc + texliveFull + + beeper + ]; + unproductivePackages = with pkgs; [ + yt-dlp + + srb2 + superTuxKart + kdePackages.kjumpingcube + kdePackages.kigo + gnugo + crawlTiles + prismlauncher + mindustry + ( + with pkgs; + import ./jgrpp-0.65.2/jgrpp-0.65.2.nix { + inherit fetchFromGitHub; + inherit openttd; + inherit zstd; + } + ) + + # retroarch-full + + wineWowPackages.staging + winetricks + + jdk # needed for stellwerksim + + chess-clock + ]; +in { nixpkgs.config.allowUnfree = false; - nix.settings.experimental-features = [ "nix-command" "flakes" ]; + nix.settings.experimental-features = [ + "nix-command" + "flakes" + ]; nix.settings.auto-optimise-store = true; nix.gc = { automatic = true; @@ -20,8 +135,9 @@ boot.loader.grub.efiSupport = true; boot.loader.efi.canTouchEfiVariables = true; boot.loader.grub.useOSProber = true; - system.nixos.label = builtins.replaceStrings [ "\n" " " ] [ "" "_" ] - (builtins.readFile ./commit_text); + system.nixos.label = builtins.replaceStrings [ "\n" " " ] [ "" "_" ] ( + builtins.readFile ./commit_text + ); # Needed for audio to work boot.kernelPackages = pkgs.linuxPackagesFor pkgs.linux_latest; @@ -88,20 +204,24 @@ users.users.esvagy = { isNormalUser = true; description = "EsVagy"; - extraGroups = [ "networkmanager" "wheel" ]; + extraGroups = [ + "networkmanager" + "wheel" + ]; initialPassword = "initialPassword"; }; programs.kdeconnect.enable = true; programs.steam = { - enable = !config.productiveBuild; + enable = true; remotePlay.openFirewall = true; dedicatedServer.openFirewall = true; localNetworkGameTransfers.openFirewall = true; }; - nixpkgs.config.allowUnfreePredicate = pkg: + nixpkgs.config.allowUnfreePredicate = + pkg: builtins.elem (pkgs.lib.getName pkg) [ "beeper" "steam" @@ -144,117 +264,14 @@ }; }; - environment.sessionVariables = { GTK_USE_PORTAL = 1; }; + environment.sessionVariables = { + GTK_USE_PORTAL = 1; + }; # List packages installed in system profile. To search, run: # $ nix search wget - environment.systemPackages = let - basePackages = with pkgs; [ - # vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default. - # wget - kdePackages.krecorder - kdePackages.kweather - kdePackages.kcharselect - kdePackages.filelight - kdePackages.kcalc - kdePackages.kclock - kdePackages.kholidays - kdePackages.akonadi-calendar - kdePackages.libkdepim - kdePackages.kdepim-addons - kdePackages.kdepim-runtime - kdePackages.kcontacts - libqalculate - qalculate-qt - - maliit-keyboard - - librewolf - kdePackages.plasma-browser-integration - kdePackages.xdg-desktop-portal-kde - - kdePackages.zanshin - kdePackages.korganizer - kdePackages.merkuro - kdePackages.francis - - wl-clipboard - lldb - kdePackages.kompare - kdePackages.kdevelop - kdePackages.kcachegrind - gcc - gdb - clang-tools - bash-language-server - nixd - nixfmt-rfc-style - marksman - kdePackages.markdownpart - lua - lua-language-server - cppcheck - nixos-shell - - kdePackages.qtwebengine - kdePackages.qtlocation - kdePackages.ksystemstats # needed for the resource widgets - aspell # needed for spell checking - aspellDicts.en - aspellDicts.hu - kdePackages.qtmultimedia - kdePackages.karousel - (with pkgs; - import ./kwin4_effect_geometry_change/kwin4_effect_geometry_change.nix { - inherit lib; - inherit stdenv; - inherit fetchFromGitHub; - kpackage = kdePackages.kpackage; - kwin = kdePackages.kwin; - inherit nodejs; - }) - - gimp - inkscape - kdePackages.kdenlive - - libreoffice - pandoc - texliveFull - - beeper - ]; - unproductivePackages = with pkgs; [ - yt-dlp - - srb2 - superTuxKart - kdePackages.kjumpingcube - kdePackages.kigo - gnugo - crawlTiles - prismlauncher - mindustry - (with pkgs; - import ./jgrpp-0.65.2/jgrpp-0.65.2.nix { - inherit fetchFromGitHub; - inherit openttd; - inherit zstd; - }) - - retroarch-full - - wineWowPackages.staging - winetricks - - jdk # needed for stellwerksim - - chess-clock - ]; - in if config.productiveBuild then - basePackages - else - basePackages ++ unproductivePackages; + # putting environment.systemPackages in specialisation does not work + environment.systemPackages = if config.specialisation != {} then basePackages ++ unproductivePackages else basePackages; fonts.packages = with pkgs; [ nerd-fonts.hack ]; @@ -272,8 +289,14 @@ # services.openssh.enable = true; # Open ports in the firewall. - networking.firewall.allowedTCPPorts = [ 2350 3450 ]; # needed for tmnf - networking.firewall.allowedUDPPorts = [ 2350 3450 ]; # needed for tmnf + networking.firewall.allowedTCPPorts = [ + 2350 + 3450 + ]; # needed for tmnf + networking.firewall.allowedUDPPorts = [ + 2350 + 3450 + ]; # needed for tmnf # Or disable the firewall altogether. # networking.firewall.enable = false; @@ -294,36 +317,51 @@ # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). system.stateVersion = "24.05"; # Did you read the comment? - services.blocky = { - enable = config.productiveBuild; - settings = { - ports.dns = 53; # Port for incoming DNS Queries. - upstreams.groups.default = [ - "https://one.one.one.one/dns-query" # Using Cloudflare's DNS over HTTPS server for resolving queries. - ]; - # For initially solving DoH/DoT Requests when no system Resolver is available. - bootstrapDns = { - upstream = "https://one.one.one.one/dns-query"; - ips = [ "1.1.1.1" "1.0.0.1" ]; - }; - #Enable Blocking of certian domains. - blocking = { - blackLists = { - unproductive = ['' - | - www.youtube.com - tilvids.com - mastodon.social - online-go.com - '']; + networking.nameservers = [ ]; + + specialisation = { + productive = { + inheritParentConfig = true; + configuration = { + programs.steam.enable = lib.mkOverride 99 false; + services.blocky = { + enable = true; + settings = { + ports.dns = 53; # port for incoming dns queries. + upstreams.groups.default = [ + "https://one.one.one.one/dns-query" # using cloudflare's dns over https server for resolving queries. + ]; + # For initially solving DoH/DoT Requests when no system Resolver is available. + bootstrapDns = { + upstream = "https://one.one.one.one/dns-query"; + ips = [ + "1.1.1.1" + "1.0.0.1" + ]; + }; + #Enable Blocking of certian domains. + blocking = { + blackLists = { + unproductive = [ + '' + | + www.youtube.com + tilvids.com + mastodon.social + online-go.com + '' + ]; + }; + #Configure what block categories are used + clientGroupsBlock = { + default = [ "unproductive" ]; + }; + }; + }; }; - #Configure what block categories are used - clientGroupsBlock = { default = [ "unproductive" ]; }; + networking.nameservers = lib.mkOverride 99 [ "127.0.0.1" ]; }; }; }; - networking.nameservers = - if config.productiveBuild then [ "127.0.0.1" ] else [ ]; } - diff --git a/flake.nix b/flake.nix index 7f1cce4..d350731 100644 --- a/flake.nix +++ b/flake.nix @@ -19,7 +19,13 @@ }; outputs = - { nixpkgs, home-manager, plasma-manager, nixvim, ... }@inputs: + { + nixpkgs, + home-manager, + plasma-manager, + nixvim, + ... + }@inputs: let system = "x86_64-linux"; pkgs = import nixpkgs { @@ -27,38 +33,29 @@ config.allowUnfree = false; }; lib = nixpkgs.lib; - in { - nixosConfigurations = let - baseSystem = { productiveBuild }: - lib.nixosSystem { - inherit system; - modules = [ - { - environment.systemPackages = - [ inputs.nixvim.packages.${system}.default ]; - } - ({ lib, ... }: { - options.productiveBuild = lib.mkOption { - type = lib.types.bool; - default = productiveBuild; - }; - }) - ./configuration.nix - ./devices/default/default.nix - home-manager.nixosModules.home-manager - { - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; - home-manager.sharedModules = - [ plasma-manager.homeManagerModules.plasma-manager ]; + in + { + nixosConfigurations = { + nixos = lib.nixosSystem { + inherit system; + modules = [ + { + environment.systemPackages = [ inputs.nixvim.packages.${system}.default ]; + } + ./configuration.nix + ./devices/default/default.nix + home-manager.nixosModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.sharedModules = [ plasma-manager.homeManagerModules.plasma-manager ]; - home-manager.users.esvagy = { imports = [ ./home.nix ]; }; - } - ]; - }; - in { - nixos = baseSystem { productiveBuild = false; }; - productive = baseSystem { productiveBuild = true; }; + home-manager.users.esvagy = { + imports = [ ./home.nix ]; + }; + } + ]; + }; }; }; } diff --git a/result b/result new file mode 120000 index 0000000..afed766 --- /dev/null +++ b/result @@ -0,0 +1 @@ +/nix/store/m7j1lj59w72b5zpqvdd8w0gmg04apyaz-nixos-system-nixos-Updated_nixvim_in_flake \ No newline at end of file