diff --git a/flake.lock b/flake.lock index c115ba0..a5b8c40 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,23 @@ { "nodes": { + "disko": { + "inputs": { + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1726842196, + "narHash": "sha256-u9h03JQUuQJ607xmti9F9Eh6E96kKUAGP+aXWgwm70o=", + "owner": "nix-community", + "repo": "disko", + "rev": "51994df8ba24d5db5459ccf17b6494643301ad28", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "disko", + "type": "github" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -7,11 +25,11 @@ ] }, "locked": { - "lastModified": 1726611255, - "narHash": "sha256-/bxaYvIK6/d3zqpW26QFS0rqfd0cO4qreSNWvYLTl/w=", + "lastModified": 1726785354, + "narHash": "sha256-SLorVhoorZwjM1aS04bBX4fufEXIfkMdAGkj9bu2QAQ=", "owner": "nix-community", "repo": "home-manager", - "rev": "d2493de5cd1da06b6a4c3e97f4e7d5dd791df457", + "rev": "1786e2afdbc48e9038f7cff585069736e1d0ed44", "type": "github" }, "original": { @@ -36,6 +54,22 @@ } }, "nixpkgs": { + "locked": { + "lastModified": 1725194671, + "narHash": "sha256-tLGCFEFTB5TaOKkpfw3iYT9dnk4awTP/q4w+ROpMfuw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "b833ff01a0d694b910daca6e2ff4a3f26dee478c", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { "locked": { "lastModified": 1726583932, "narHash": "sha256-zACxiQx8knB3F8+Ze+1BpiYrI+CbhxyWpcSID9kVhkQ=", @@ -53,9 +87,10 @@ }, "root": { "inputs": { + "disko": "disko", "home-manager": "home-manager", "nix-flatpak": "nix-flatpak", - "nixpkgs": "nixpkgs", + "nixpkgs": "nixpkgs_2", "stable": "stable" } }, diff --git a/flake.nix b/flake.nix index 2056ddd..e5244e9 100644 --- a/flake.nix +++ b/flake.nix @@ -8,28 +8,39 @@ nix-flatpak.url = "github:gmodena/nix-flatpak"; home-manager = { - url = "github:nix-community/home-manager"; - inputs.nixpkgs.follows = "nixpkgs"; + url = "github:nix-community/home-manager"; + inputs.nixpkgs.follows = "nixpkgs"; }; + + disko.url = "github:nix-community/disko"; }; - outputs = inputs@{ self, nixpkgs, ... }: { - # Please replace my-nixos with your hostname - nixosConfigurations = { + outputs = + inputs@{ self, nixpkgs, ... }: + { + # Please replace my-nixos with your hostname + nixosConfigurations = { work-ntb = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - modules = [ - ./hosts/work-ntb - inputs.nix-flatpak.nixosModules.nix-flatpak - inputs.home-manager.nixosModules.home-manager - ]; - specialArgs = { - hostname = "work-ntb"; - }; - }; - extraSpecialArgs = { - inherit inputs; - }; + system = "x86_64-linux"; + modules = [ + ./hosts/work-ntb + ./hosts/base + ]; + specialArgs = { + inherit inputs; + }; }; + lenar = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + ./hosts/lenar + ./hosts/base + ]; + specialArgs = { + inherit inputs; + }; + }; + }; + formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.nixfmt-rfc-style; }; } diff --git a/hosts/base/default.nix b/hosts/base/default.nix index b909cf9..70ef43a 100644 --- a/hosts/base/default.nix +++ b/hosts/base/default.nix @@ -2,26 +2,28 @@ # your system. Help is available in the configuration.nix(5) man page # and in the NixOS manual (accessible by running ‘nixos-help’). -{ config, pkgs, hostname, ... }: +{ + config, + pkgs, + inputs, + ... +}: { - imports = - [ # Include the results of the hardware scan. - ../${hostname}/hardware-configuration.nix - ../../modules/dev - ]; + + imports = [ + inputs.home-manager.nixosModules.home-manager # TODO: move to base + inputs.nix-flatpak.nixosModules.nix-flatpak # TODO: move to base + ../../nixosModules + ]; # Bootloader. - boot.loader.systemd-boot.enable = true; - boot.loader.efi.canTouchEfiVariables = true; - - networking.hostName = hostname; # Define your hostname. + boot.loader = { + systemd-boot.enable = true; + efi.canTouchEfiVariables = true; + }; # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. Not needed if using GNOME - # Configure network proxy if necessary - # networking.proxy.default = "http://user:password@proxy:port/"; - # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain"; - # Enable networking networking.networkmanager.enable = true; @@ -44,11 +46,13 @@ }; # Enable the X11 windowing system. - services.xserver.enable = true; + services.xserver = { + enable = true; + # Enable the GNOME Desktop Environment. + displayManager.gdm.enable = true; + desktopManager.gnome.enable = true; + }; - # Enable the GNOME Desktop Environment. - services.xserver.displayManager.gdm.enable = true; - services.xserver.desktopManager.gnome.enable = true; services.gnome.gnome-browser-connector.enable = true; environment.gnome.excludePackages = with pkgs; [ @@ -69,8 +73,8 @@ # Enable CUPS to print documents. services.printing = { - enable = true; - drivers = [ pkgs.samsung-unified-linux-driver ]; + enable = true; + drivers = [ pkgs.samsung-unified-linux-driver ]; }; # Enable sound with pipewire. @@ -96,17 +100,21 @@ users.users.krop = { isNormalUser = true; description = "Jakub Kropacek"; - extraGroups = [ "networkmanager" "wheel" ]; + extraGroups = [ + "networkmanager" + "wheel" + ]; shell = pkgs.zsh; }; - # Allow unfree packages nixpkgs.config.allowUnfree = true; - # Enable flakes - nix.settings.experimental-features = [ "nix-command" "flakes" ]; + nix.settings.experimental-features = [ + "nix-command" + "flakes" + ]; # List packages installed in system profile. To search, run: # $ nix search wget @@ -121,13 +129,13 @@ mattermost-desktop gh gparted - dig + dig prismlauncher # REMOVE AND MOVE TO games module after refactoring gnome-extension-manager # DEBUG gnomeExtensions.grand-theft-focus + joplin-desktop ]; - programs = { tmux.enable = true; zsh.enable = true; @@ -142,14 +150,20 @@ services.flatpak = { enable = true; remotes = [ - { name = "flathub"; location = "https://dl.flathub.org/repo/flathub.flatpakrepo"; } - { name = "flathub-beta"; location = "https://flathub.org/beta-repo/flathub-beta.flatpakrepo"; } + { + name = "flathub"; + location = "https://dl.flathub.org/repo/flathub.flatpakrepo"; + } + { + name = "flathub-beta"; + location = "https://flathub.org/beta-repo/flathub-beta.flatpakrepo"; + } ]; packages = [ - "org.gnome.World.PikaBackup" - "ca.desrt.dconf-editor" - "org.onlyoffice.desktopeditors" - "tv.kodi.Kodi" + "org.gnome.World.PikaBackup" + "ca.desrt.dconf-editor" + "org.onlyoffice.desktopeditors" + "tv.kodi.Kodi" ]; }; diff --git a/hosts/lenar/default.nix b/hosts/lenar/default.nix new file mode 100644 index 0000000..01a4b3c --- /dev/null +++ b/hosts/lenar/default.nix @@ -0,0 +1,34 @@ +{ + config, + pkgs, + inputs, + ... +}: +{ + imports = [ + # Include the results of the hardware scan. + ./hardware-configuration.nix + inputs.disko.nixosModules.disko + ./disko.nix + ]; + + networking.hostName = "lenar"; # Define your hostname. + + # My own modules configuration + krop = { + ide = { + enable = true; + install-pycharm = true; + }; + python.install-older = true; + }; + + home-manager = { + extraSpecialArgs = { + inherit inputs; + }; + users = { + "krop" = import ./home.nix; + }; + }; +} diff --git a/hosts/lenar/disko.nix b/hosts/lenar/disko.nix new file mode 100644 index 0000000..8a35c81 --- /dev/null +++ b/hosts/lenar/disko.nix @@ -0,0 +1,53 @@ +{ + disko.devices = { + disk = { + main = { + type = "disk"; + device = "/dev/nvme0n1"; + content = { + type = "gpt"; + partitions = { + ESP = { + priority = 1; + name = "ESP"; + start = "1M"; + end = "128M"; + type = "EF00"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + }; + }; + root = { + size = "100%"; + content = { + type = "btrfs"; + extraArgs = [ "-f" ]; # Override existing partition + # Subvolumes must set a mountpoint in order to be mounted, + # unless their parent is mounted + subvolumes = { + # Subvolume name is different from mountpoint + "/rootfs" = { + mountpoint = "/"; + }; + # Subvolume name is the same as the mountpoint + "/home" = { + mountOptions = [ "compress=zstd" ]; + mountpoint = "/home"; + }; + # Parent is not mounted so the mountpoint must be set + "/nix" = { + mountOptions = [ "compress=zstd" "noatime" ]; + mountpoint = "/nix"; + }; + }; + mountpoint = "/partition-root"; + }; + }; + }; + }; + }; + }; + }; +} \ No newline at end of file diff --git a/hosts/lenar/hardware-configuration.nix b/hosts/lenar/hardware-configuration.nix new file mode 100644 index 0000000..39024d8 --- /dev/null +++ b/hosts/lenar/hardware-configuration.nix @@ -0,0 +1,22 @@ +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = + [ (modulesPath + "/installer/scan/not-detected.nix") + ]; + + boot.initrd.availableKernelModules = [ "xhci_pci" "thunderbolt" "vmd" "nvme" "usb_storage" "sd_mod" "sdhci_pci" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + # 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.wlo1.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} \ No newline at end of file diff --git a/hosts/lenar/home.nix b/hosts/lenar/home.nix new file mode 100644 index 0000000..31dcc03 --- /dev/null +++ b/hosts/lenar/home.nix @@ -0,0 +1,147 @@ +{ config, pkgs, ... }: + +{ + home.username = "krop"; + home.homeDirectory = "/home/krop"; + + # This value determines the Home Manager release that your configuration is + # compatible with. This helps avoid breakage when a new Home Manager release + # introduces backwards incompatible changes. + # + # You should not change this value, even if you update Home Manager. If you do + # want to update the value, then make sure to first check the Home Manager + # release notes. + home.stateVersion = "24.05"; # Please read the comment before changing. + + # The home.packages option allows you to install Nix packages into your + # environment. + home.packages = with pkgs; [ + gnomeExtensions.grand-theft-focus + # # Adds the 'hello' command to your environment. It prints a friendly + # # "Hello, world!" when run. + # hello + + # # It is sometimes useful to fine-tune packages, for example, by applying + # # overrides. You can do that directly here, just don't forget the + # # parentheses. Maybe you want to install Nerd Fonts with a limited number of + # # fonts? + # (nerdfonts.override { fonts = [ "FantasqueSansMono" ]; }) + + # # You can also create simple shell scripts directly inside your + # # configuration. For example, this adds a command 'my-hello' to your + # # environment: + # (writeShellScriptBin "my-hello" '' + # echo "Hello, ${config.home.username}!" + # '') + ]; + + # Home Manager is pretty good at managing dotfiles. The primary way to manage + # plain files is through 'home.file'. + home.file = { + # # Building this configuration will create a copy of 'dotfiles/screenrc' in + # # the Nix store. Activating the configuration will then make '~/.screenrc' a + # # symlink to the Nix store copy. + # ".screenrc".source = dotfiles/screenrc; + + # # You can also set the file content immediately. + # ".gradle/gradle.properties".text = '' + # org.gradle.console=verbose + # org.gradle.daemon.idletimeout=3600000 + # ''; + }; + + # Home Manager can also manage your environment variables through + # 'home.sessionVariables'. These will be explicitly sourced when using a + # shell provided by Home Manager. If you don't want to manage your shell + # through Home Manager then you have to manually source 'hm-session-vars.sh' + # located at either + # + # ~/.nix-profile/etc/profile.d/hm-session-vars.sh + # + # or + # + # ~/.local/state/nix/profiles/profile/etc/profile.d/hm-session-vars.sh + # + # or + # + # /etc/profiles/per-user/krop/etc/profile.d/hm-session-vars.sh + # + home.sessionVariables = { + # EDITOR = "emacs"; + }; + + dconf = { + enable = true; + settings."org/gnome/shell" = { + disable-user-extensions = false; + enabled-extensions = with pkgs.gnomeExtensions; [ + grand-theft-focus.extensionUuid + ]; + }; + }; + + gtk = { + enable = true; + gtk3.extraConfig = { + Settings = '' + gtk-application-prefer-dark-theme=1 + ''; + }; + gtk4.extraConfig = { + Settings = '' + gtk-application-prefer-dark-theme=1 + ''; + }; + }; + + qt = { + enable = true; + platformTheme.name = "adwaita"; # TODO: fix themes + style.name = "adwaita-dark"; + }; + + programs.git = { + enable = true; + userName = "Jakub Kropáček"; + userEmail = "kropikuba@gmail.com"; + includes = + let + workcfg = { + user = { + email = "jakub.kropacek@olc.cz"; + name = "Jakub Kropáček"; + }; + }; + in + [ + { + condition = "gitdir:~/Repositories/OLC/**"; + contents = workcfg; + } + { + condition = "gitdir:~/Repositories/OLC-Hexpol/**"; + contents = workcfg; + } + ]; + extraConfig = { + init = { + defaultBranch = "master"; + }; + push = { + autoSetupRemote = true; + }; + status = { + submoduleSummary = true; + }; + diff = { + submodule = "log"; + }; + core = { + autocrlf = "input"; + }; + }; + }; + + # Let Home Manager install and manage itself. + programs.home-manager.enable = true; +} diff --git a/hosts/work-ntb/default.nix b/hosts/work-ntb/default.nix index eb6b9eb..fdf1835 100644 --- a/hosts/work-ntb/default.nix +++ b/hosts/work-ntb/default.nix @@ -1,15 +1,32 @@ -{config, pkgs, inputs, ...}: { - imports = [ - (import ../base {inherit config pkgs; hostname = "work-ntb"; }) - ]; +{ + config, + pkgs, + inputs, + ... +}: +{ + imports = [ + # Include the results of the hardware scan. + ./hardware-configuration.nix + ]; - # My own modules configuration - krop.devtools.installIDE = true; + networking.hostName = "work-ntb"; # Define your hostname. - home-manager = { - extraSpecialArgs = { inherit inputs; }; - users = { - "krop" = import ./home.nix; - }; + # My own modules configuration + krop = { + ide = { + enable = true; + install-pycharm = true; }; + python.install-older = true; + }; + + home-manager = { + extraSpecialArgs = { + inherit inputs; + }; + users = { + "krop" = import ./home.nix; + }; + }; } diff --git a/hosts/work-ntb/hardware-configuration.nix b/hosts/work-ntb/hardware-configuration.nix index 4275253..6d29069 100644 --- a/hosts/work-ntb/hardware-configuration.nix +++ b/hosts/work-ntb/hardware-configuration.nix @@ -1,28 +1,43 @@ # 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, ... }: +{ + config, + lib, + pkgs, + modulesPath, + ... +}: { - imports = - [ (modulesPath + "/installer/scan/not-detected.nix") - ]; + imports = [ + (modulesPath + "/installer/scan/not-detected.nix") + ]; - boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "usb_storage" "sd_mod" "rtsx_pci_sdmmc" ]; + boot.initrd.availableKernelModules = [ + "xhci_pci" + "ahci" + "usb_storage" + "sd_mod" + "rtsx_pci_sdmmc" + ]; boot.initrd.kernelModules = [ ]; boot.kernelModules = [ "kvm-intel" ]; boot.extraModulePackages = [ ]; - fileSystems."/" = - { device = "/dev/disk/by-uuid/360cfb7a-07d9-445b-83e2-6ef19bd55948"; - fsType = "ext4"; - }; + fileSystems."/" = { + device = "/dev/disk/by-uuid/360cfb7a-07d9-445b-83e2-6ef19bd55948"; + fsType = "ext4"; + }; - fileSystems."/boot" = - { device = "/dev/disk/by-uuid/5F8E-3C09"; - fsType = "vfat"; - options = [ "fmask=0077" "dmask=0077" ]; - }; + fileSystems."/boot" = { + device = "/dev/disk/by-uuid/5F8E-3C09"; + fsType = "vfat"; + options = [ + "fmask=0077" + "dmask=0077" + ]; + }; swapDevices = [ ]; diff --git a/hosts/work-ntb/home.nix b/hosts/work-ntb/home.nix index 40713cb..31dcc03 100644 --- a/hosts/work-ntb/home.nix +++ b/hosts/work-ntb/home.nix @@ -83,14 +83,14 @@ gtk = { enable = true; gtk3.extraConfig = { - Settings = '' + Settings = '' gtk-application-prefer-dark-theme=1 - ''; + ''; }; gtk4.extraConfig = { - Settings = '' + Settings = '' gtk-application-prefer-dark-theme=1 - ''; + ''; }; }; @@ -100,17 +100,20 @@ style.name = "adwaita-dark"; }; - programs.git = { enable = true; userName = "Jakub Kropáček"; userEmail = "kropikuba@gmail.com"; - includes = let workcfg = { - user = { - email = "jakub.kropacek@olc.cz"; - name = "Jakub Kropáček"; - }; - }; in [ + includes = + let + workcfg = { + user = { + email = "jakub.kropacek@olc.cz"; + name = "Jakub Kropáček"; + }; + }; + in + [ { condition = "gitdir:~/Repositories/OLC/**"; contents = workcfg; @@ -119,23 +122,23 @@ condition = "gitdir:~/Repositories/OLC-Hexpol/**"; contents = workcfg; } - ]; + ]; extraConfig = { - init = { - defaultBranch = "master"; - }; - push = { - autoSetupRemote = true; - }; - status = { - submoduleSummary = true; - }; - diff = { - submodule = "log"; - }; - core = { - autocrlf = "input"; - }; + init = { + defaultBranch = "master"; + }; + push = { + autoSetupRemote = true; + }; + status = { + submoduleSummary = true; + }; + diff = { + submodule = "log"; + }; + core = { + autocrlf = "input"; + }; }; }; diff --git a/modules/dev/default.nix b/modules/dev/default.nix deleted file mode 100644 index e4f5078..0000000 --- a/modules/dev/default.nix +++ /dev/null @@ -1,43 +0,0 @@ -{ config, pkgs, lib, ... }@inputs: -let - cfg = config.krop.devtools; -in { - options.krop.devtools = { - installIDE = lib.mkOption { - type = lib.types.bool; - default = false; - example = true; - description = "Whether to install the ides"; - }; - installTools = lib.mkOption { - type = lib.types.bool; - default = true; - example = true; - description = "Whether to install the most used tools"; - }; - }; - config = let - ides = with pkgs; [ - jetbrains.pycharm-professional - zed-editor - vscodium - ]; - languages = with pkgs; [ - python3 - python311 - python310 - poetry - ]; - tools = with pkgs; [ - lazygit - lazydocker - micro-with-wl-clipboard - albert - openssl_3_3 - ]; - in { - environment.systemPackages = languages - ++ (lib.optionals cfg.installIDE ides) - ++ (lib.optionals cfg.installTools tools); - }; -} diff --git a/nixosModules/default.nix b/nixosModules/default.nix new file mode 100644 index 0000000..0fd9687 --- /dev/null +++ b/nixosModules/default.nix @@ -0,0 +1,6 @@ +{ ... }: +{ + imports = [ + ./dev + ]; +} diff --git a/nixosModules/dev/default.nix b/nixosModules/dev/default.nix new file mode 100644 index 0000000..c9891b7 --- /dev/null +++ b/nixosModules/dev/default.nix @@ -0,0 +1,37 @@ +{ + config, + pkgs, + lib, + ... +}@inputs: +let + cfg = config.krop.devtools; +in +{ + imports = [ + ./python.nix + ./ide.nix + ]; + options.krop.devtools = { + installTools = lib.mkOption { + type = lib.types.bool; + default = true; + example = true; + description = "Whether to install the most used tools"; + }; + }; + + config = + let + tools = with pkgs; [ + lazygit + lazydocker + micro-with-wl-clipboard + albert + openssl_3_3 + ]; + in + { + environment.systemPackages = tools; + }; +} diff --git a/nixosModules/dev/go.nix b/nixosModules/dev/go.nix new file mode 100644 index 0000000..26739a1 --- /dev/null +++ b/nixosModules/dev/go.nix @@ -0,0 +1,4 @@ +{ + ... +}: +{ } diff --git a/nixosModules/dev/ide.nix b/nixosModules/dev/ide.nix new file mode 100644 index 0000000..161622c --- /dev/null +++ b/nixosModules/dev/ide.nix @@ -0,0 +1,32 @@ +{ + config, + pkgs, + lib, + ... +}: +let + cfg = config.krop.ide; +in +{ + options.krop.ide = { + enable = lib.mkOption { + type = lib.types.bool; + default = true; + example = true; + }; + install-pycharm = lib.mkOption { + type = lib.types.bool; + default = false; + example = true; + }; + }; + config = lib.mkIf cfg.enable { + environment.systemPackages = + with pkgs; + [ + zed-editor + vscodium + ] + ++ lib.optionals cfg.install-pycharm [ pkgs.jetbrains.pycharm-professional ]; + }; +} diff --git a/nixosModules/dev/python.nix b/nixosModules/dev/python.nix new file mode 100644 index 0000000..ab730ae --- /dev/null +++ b/nixosModules/dev/python.nix @@ -0,0 +1,36 @@ +{ + config, + pkgs, + lib, + ... +}: +let + cfg = config.krop.python; +in +{ + options.krop.python = { + enable = lib.mkOption { + type = lib.types.bool; + default = false; + example = true; + }; + install-older = lib.mkOption { + type = lib.types.bool; + default = true; + example = true; + }; + }; + + config = lib.mkIf cfg.enable { + environment.systemPackages = + with pkgs; + [ + python3 + poetry + ] + ++ lib.optionals cfg.install-older [ + python311 + python310 + ]; + }; +}