diff --git a/default.nix b/default.nix deleted file mode 100644 index d3dfb20..0000000 --- a/default.nix +++ /dev/null @@ -1,33 +0,0 @@ -{ config, lib, pkgs, ... }: - -{ - imports = [ - # TODO: Temporary until it has been subdivided into modules. - ./merged.nix - - # Modules - ./modules/default.nix - - # System configuration options - ./system.nix - - # Import test configuration - ./test.nix - ]; - - config = { - # Allow unfree packages - nixpkgs.config.allowUnfree = true; - - # Enable default modules - modules = { - # Greeter - tuigreet.enable = true; - }; - - # Localization settings - time.timeZone = "Europe/Amsterdam"; - i18n.defaultLocale = "en_US.UTF-8"; - console.keyMap = "us"; - }; -} \ No newline at end of file diff --git a/machines/laptop.nix b/machines/laptop.nix new file mode 100644 index 0000000..5eaf703 --- /dev/null +++ b/machines/laptop.nix @@ -0,0 +1,31 @@ +{ ... }: + +{ + imports = [ + # Import modules + ../modules/default.nix + + # TODO: Remove later + ../merged.nix + ]; + + config = { + # State version + system.stateVersion = "24.05"; + + # Machine hostname + networking.hostName = "20212060"; + + # Enabled modules + modules = { + pipewire.enable = true; + wpa_supplicant.enable = true; + }; + + # User accounts + machine.users.jan = { + sudo = true; + configuration = ../users/jan.nix; + }; + }; +} \ No newline at end of file diff --git a/merged.nix b/merged.nix index 413f932..f26abe0 100644 --- a/merged.nix +++ b/merged.nix @@ -5,9 +5,9 @@ { config, lib, pkgs, ... }: let - nixvim = import (builtins.fetchGit { - url = "https://github.com/nix-community/nixvim"; - }); + # nixvim = import (builtins.fetchGit { + # url = "https://github.com/nix-community/nixvim"; + # }); # stylix = import (pkgs.fetchFromGitHub { # owner = "danth"; # repo = "stylix"; @@ -131,10 +131,12 @@ in { # }; # Set up networking - networking.wireless.userControlled.enable = true; - networking.hostName = "20212060"; # Define your hostname. - networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. - networking.wireless.allowAuxiliaryImperativeNetworks = true; + # networking.wireless.userControlled.enable = true; + # networking.hostName = "20212060"; # Define your hostname. + # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. + # networking.wireless.allowAuxiliaryImperativeNetworks = true; + + nixpkgs.config.allowUnfree = true; # Set up graphics hardware.graphics.enable32Bit = true; @@ -158,10 +160,10 @@ in { }; # Set up tailscale - services.tailscale = { - enable = true; - useRoutingFeatures = "client"; - }; + # services.tailscale = { + # enable = true; + # useRoutingFeatures = "client"; + # }; # Set time zone. # time.timeZone = "Europe/Amsterdam"; @@ -173,11 +175,11 @@ in { # nixpkgs.config.allowUnfree = true; # Enable sound - services.pipewire = { - enable = true; - alsa.enable = true; - pulse.enable = true; - }; + # services.pipewire = { + # enable = true; + # alsa.enable = true; + # pulse.enable = true; + # }; # Set up input services.libinput.enable = true; @@ -197,7 +199,7 @@ in { # security.pam.services.waylock = {}; # Enable programs - programs.river.enable = true; + # programs.river.enable = true; xdg.portal = { enable = true; @@ -209,7 +211,7 @@ in { }; # Gamer moment - programs.steam.enable = true; + # programs.steam.enable = true; # Define a user account. Don't forget to set a password with ‘passwd’. # users.users.jan = { @@ -220,10 +222,7 @@ in { # home-manager.backupFileExtension = "bak"; # Global neovim - programs.neovim = { - enable = true; - defaultEditor = true; - }; + # pr` # dconf programs.dconf.enable = true; diff --git a/modules/default.nix b/modules/default.nix index b7ce727..1b43ab1 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -1,9 +1,23 @@ { lib, config, pkgs, ... }: -{ +with lib; { imports = [ - ./greetd/default.nix - ./tuigreet/default.nix + # Import modules + ./greeter/greetd/default.nix + ./greeter/greetd/tuigreet.nix + ./locale/default.nix + ./neovim/default.nix + ./sound/pipewire.nix ./users/default.nix + ./unfree/default.nix + ./vpn/tailscale.nix + ./wifi/wpa_supplicant.nix ]; + + config.modules = { + # Enable default modules + neovim.enable = mkDefault true; + tuigreet.enable = mkDefault true; + tailscale.enable = mkDefault true; + }; } \ No newline at end of file diff --git a/modules/greetd/default.nix b/modules/greeter/greetd/default.nix similarity index 100% rename from modules/greetd/default.nix rename to modules/greeter/greetd/default.nix diff --git a/modules/tuigreet/default.nix b/modules/greeter/greetd/tuigreet.nix similarity index 100% rename from modules/tuigreet/default.nix rename to modules/greeter/greetd/tuigreet.nix diff --git a/modules/locale/default.nix b/modules/locale/default.nix new file mode 100644 index 0000000..621f383 --- /dev/null +++ b/modules/locale/default.nix @@ -0,0 +1,9 @@ +{ lib, config, pkgs, ... }: + +{ + config = { + time.timeZone = "Europe/Amsterdam"; + i18n.defaultLocale = "en_US.UTF-8"; + console.keyMap = "us"; + }; +} \ No newline at end of file diff --git a/modules/neovim/default.nix b/modules/neovim/default.nix new file mode 100644 index 0000000..7046e42 --- /dev/null +++ b/modules/neovim/default.nix @@ -0,0 +1,17 @@ +{ lib, config, pkgs, ... }: + +with lib; +let + cfg = config.modules.neovim; +in { + options.modules.neovim = { + enable = mkEnableOption "neovim"; + }; + + config = mkIf cfg.enable { + programs.neovim = { + enable = true; + defaultEditor = true; + }; + }; +} \ No newline at end of file diff --git a/modules/silent-boot/default.nix b/modules/silent-boot/default.nix deleted file mode 100644 index e69de29..0000000 diff --git a/modules/sound/pipewire.nix b/modules/sound/pipewire.nix new file mode 100644 index 0000000..202d881 --- /dev/null +++ b/modules/sound/pipewire.nix @@ -0,0 +1,18 @@ +{ lib, config, pkgs, ... }: + +with lib; +let + cfg = config.modules.pipewire; +in { + options.modules.pipewire = { + enable = mkEnableOption "pipewire"; + }; + + config = mkIf cfg.enable { + services.pipewire = { + enable = true; + alsa.enable = true; + pulse.enable = true; + }; + }; +} \ No newline at end of file diff --git a/modules/unfree/default.nix b/modules/unfree/default.nix new file mode 100644 index 0000000..ba3e5cc --- /dev/null +++ b/modules/unfree/default.nix @@ -0,0 +1,18 @@ +{ lib, config, pkgs, ... }: + +with lib; +let + cfg = config.modules.unfree; +in { + options.modules.unfree = { + enable = mkEnableOption "unfree"; + allowedPackages = mkOption { + type = types.listOf types.str; + default = []; + }; + }; + + config = mkIf cfg.enable { + nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (getName pkg) cfg.allowedPackages; + }; +} \ No newline at end of file diff --git a/modules/users/default.nix b/modules/users/default.nix index 308304c..e38b11d 100644 --- a/modules/users/default.nix +++ b/modules/users/default.nix @@ -42,7 +42,7 @@ in { # Import system wide configuration required for user modules - ./systemwide/waylock.nix + ./modules/systemwide/default.nix ]; options = { diff --git a/modules/users/modules/default.nix b/modules/users/modules/default.nix index 602872d..a1f132d 100644 --- a/modules/users/modules/default.nix +++ b/modules/users/modules/default.nix @@ -1,19 +1,22 @@ { input, pkgs, config, ... }: -{ - # Set the state version - home.stateVersion = "24.05"; - +{ imports = [ # Import all modules ./desktop/default.nix + ./discord/default.nix ./feishin/default.nix ./firefox/default.nix ./obsidian/default.nix ./shell/bash.nix ./shell/fish.nix + ./steam/default.nix ./theming/default.nix ./vscode/default.nix + ./winbox/default.nix ./zathura/default.nix + + # Import unfree helper + ../../unfree/default.nix ]; } diff --git a/modules/users/modules/discord/default.nix b/modules/users/modules/discord/default.nix new file mode 100644 index 0000000..bd59ac4 --- /dev/null +++ b/modules/users/modules/discord/default.nix @@ -0,0 +1,18 @@ +{config, lib, pkgs, ... }: + +with lib; +let + cfg = config.modules.discord; +in { + options.modules.discord = { + enable = mkEnableOption "discord"; + }; + + config = mkIf cfg.enable { + modules.unfree.allowedPackages = [ "discord" ]; + + home.packages = with pkgs; [ + discord + ]; + }; +} \ No newline at end of file diff --git a/modules/users/modules/obsidian/default.nix b/modules/users/modules/obsidian/default.nix index 5971cd6..76ab95a 100644 --- a/modules/users/modules/obsidian/default.nix +++ b/modules/users/modules/obsidian/default.nix @@ -1,11 +1,14 @@ {config, lib, pkgs, ... }: +with lib; let cfg = config.modules.obsidian; in { - options.modules.obsidian.enable = lib.mkEnableOption "obsidian"; + options.modules.obsidian = { + enable = mkEnableOption "obsidian"; + }; - config = lib.mkIf cfg.enable { + config = mkIf cfg.enable { home.packages = with pkgs; [ obsidian ]; diff --git a/modules/users/modules/steam/default.nix b/modules/users/modules/steam/default.nix new file mode 100644 index 0000000..bdbc46d --- /dev/null +++ b/modules/users/modules/steam/default.nix @@ -0,0 +1,7 @@ +{config, lib, pkgs, ... }: + +with lib; { + options.modules.steam = { + enable = mkEnableOption "steam"; + }; +} \ No newline at end of file diff --git a/modules/users/modules/systemwide/default.nix b/modules/users/modules/systemwide/default.nix new file mode 100644 index 0000000..371e114 --- /dev/null +++ b/modules/users/modules/systemwide/default.nix @@ -0,0 +1,10 @@ +{ ... }: + +{ + imports = [ + # Import systemwide configuration files. + ./river.nix + ./steam.nix + ./waylock.nix + ]; +} \ No newline at end of file diff --git a/modules/users/modules/systemwide/river.nix b/modules/users/modules/systemwide/river.nix new file mode 100644 index 0000000..3645fff --- /dev/null +++ b/modules/users/modules/systemwide/river.nix @@ -0,0 +1,10 @@ +{ lib, config, pkgs, ... }: + +with lib; +let + enabled = any (user: user.modules.river.enable) (attrValues config.home-manager.users); +in { + config = mkIf enabled { + programs.river.enable = true; + }; +} \ No newline at end of file diff --git a/modules/users/modules/systemwide/steam.nix b/modules/users/modules/systemwide/steam.nix new file mode 100644 index 0000000..5358543 --- /dev/null +++ b/modules/users/modules/systemwide/steam.nix @@ -0,0 +1,10 @@ +{ lib, config, pkgs, ... }: + +with lib; +let + enabled = any (user: user.modules.steam.enable) (attrValues config.home-manager.users); +in { + config = mkIf enabled { + programs.steam.enable = true; + }; +} \ No newline at end of file diff --git a/modules/users/systemwide/waylock.nix b/modules/users/modules/systemwide/waylock.nix similarity index 100% rename from modules/users/systemwide/waylock.nix rename to modules/users/modules/systemwide/waylock.nix diff --git a/modules/users/modules/vscode/default.nix b/modules/users/modules/vscode/default.nix index 1b27268..b20c085 100644 --- a/modules/users/modules/vscode/default.nix +++ b/modules/users/modules/vscode/default.nix @@ -6,6 +6,8 @@ in { options.modules.vscode.enable = lib.mkEnableOption "vscode"; config = lib.mkIf cfg.enable { + modules.unfree.allowedPackages = [ "vscode" ]; + home.packages = with pkgs; [ vscode ]; diff --git a/modules/users/modules/winbox/default.nix b/modules/users/modules/winbox/default.nix new file mode 100644 index 0000000..9499ba8 --- /dev/null +++ b/modules/users/modules/winbox/default.nix @@ -0,0 +1,18 @@ +{config, lib, pkgs, ... }: + +with lib; +let + cfg = config.modules.winbox; +in { + options.modules.winbox = { + enable = mkEnableOption "winbox"; + }; + + config = mkIf cfg.enable { + modules.unfree.allowedPackages = [ "winbox" ]; + + home.packages = with pkgs; [ + winbox + ]; + }; +} \ No newline at end of file diff --git a/modules/vpn/tailscale.nix b/modules/vpn/tailscale.nix new file mode 100644 index 0000000..2371be2 --- /dev/null +++ b/modules/vpn/tailscale.nix @@ -0,0 +1,17 @@ +{ lib, config, pkgs, ... }: + +with lib; +let + cfg = config.modules.tailscale; +in { + options.modules.tailscale = { + enable = mkEnableOption "tailscale"; + }; + + config = mkIf cfg.enable { + services.tailscale = { + enable = true; + useRoutingFeatures = "client"; + }; + }; +} \ No newline at end of file diff --git a/modules/wifi/wpa_supplicant.nix b/modules/wifi/wpa_supplicant.nix new file mode 100644 index 0000000..a1a0b92 --- /dev/null +++ b/modules/wifi/wpa_supplicant.nix @@ -0,0 +1,18 @@ +{ lib, config, pkgs, ... }: + +with lib; +let + cfg = config.modules.wpa_supplicant; +in { + options.modules.wpa_supplicant = { + enable = mkEnableOption "wpa_supplicant"; + }; + + config = mkIf cfg.enable { + networking.wireless = { + enable = true; + userControlled.enable = true; + allowAuxiliaryImperativeNetworks = true; + }; + }; +} \ No newline at end of file diff --git a/system.nix b/system.nix deleted file mode 100644 index 4a39ac7..0000000 --- a/system.nix +++ /dev/null @@ -1,12 +0,0 @@ -{ config, lib, pkgs, ... }: - -{ - options = { - machine.laptop = lib.mkOption { - type = lib.types.bool; - default = false; - example = true; - description = "Whether the current system is a laptop."; - }; - }; -} \ No newline at end of file diff --git a/test.nix b/test.nix deleted file mode 100644 index f655d1b..0000000 --- a/test.nix +++ /dev/null @@ -1,17 +0,0 @@ -{ config, lib, pkgs, ... }: - -{ - config = { - system.stateVersion = "24.05"; - - machine.users.jan = { - sudo = true; - configuration = ./users/jan.nix; - }; - - machine.users.second = { - sudo = false; - configuration = ./users/jan.nix; - }; - }; -} \ No newline at end of file diff --git a/users/jan.nix b/users/jan.nix index bdfaa9c..50bc327 100644 --- a/users/jan.nix +++ b/users/jan.nix @@ -11,9 +11,6 @@ # State version home.stateVersion = "24.05"; - # Allow unfree software such as vscode - nixpkgs.config.allowUnfree = true; - modules = { # Window manager river.enable = true; @@ -25,6 +22,11 @@ vscode.enable = true; zathura.enable = true; fish.enable = true; + winbox.enable = true; + discord.enable = true; + + # Enable unfree + unfree.enable = true; }; theming.themes.gruvbox = { diff --git a/users/janMerged.nix b/users/janMerged.nix index 969c65a..e81450d 100644 --- a/users/janMerged.nix +++ b/users/janMerged.nix @@ -18,11 +18,11 @@ in { # Packages home.packages = with pkgs; [ # Programs - vscode - feishin - discord - obsidian - winbox + # vscode + # feishin + # discord + # obsidian + # winbox # Utilities pulsemixer