diff --git a/machines/configuration.nix b/machines/configuration.nix index 2ebb3b6..8df766e 100644 --- a/machines/configuration.nix +++ b/machines/configuration.nix @@ -1,156 +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, ... }: - -{ - imports = - [ # Include the results of the hardware scan. - ./hardware-configuration.nix - ]; - - # Bootloader. - boot.loader.grub.enable = true; - boot.loader.grub.device = "/dev/sda"; - boot.loader.grub.useOSProber = true; - - networking.hostName = "nixos"; # Define your hostname. - # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. - - # 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; - - # Set your time zone. - time.timeZone = "Europe/Berlin"; - - # Select internationalisation properties. - i18n.defaultLocale = "en_US.UTF-8"; - - i18n.extraLocaleSettings = { - LC_ADDRESS = "de_DE.UTF-8"; - LC_IDENTIFICATION = "de_DE.UTF-8"; - LC_MEASUREMENT = "de_DE.UTF-8"; - LC_MONETARY = "de_DE.UTF-8"; - LC_NAME = "de_DE.UTF-8"; - LC_NUMERIC = "de_DE.UTF-8"; - LC_PAPER = "de_DE.UTF-8"; - LC_TELEPHONE = "de_DE.UTF-8"; - LC_TIME = "de_DE.UTF-8"; +{ self, ... }: +let + inherit + (self.inputs) + nixpkgs + nixpkgs-unstable + sops-nix + nixos-hardware + passworts + ; + nixosSystem = nixpkgs.lib.makeOverridable nixpkgs.lib.nixosSystem; + overlay-unstable = final: prev: { + unstable = import nixpkgs-unstable { + inherit (final) system; + config.allowUnfree = true; + }; }; - # Enable the X11 windowing system. - services.xserver.enable = true; - - # Enable the GNOME Desktop Environment. - services.xserver.displayManager.gdm.enable = true; - services.xserver.desktopManager.gnome.enable = true; - - # Configure keymap in X11 - services.xserver = { - layout = "de"; - xkbVariant = ""; - }; - - # Configure console keymap - console.keyMap = "de"; - - # Enable CUPS to print documents. - services.printing.enable = true; - - # Enable sound with pipewire. - sound.enable = true; - hardware.pulseaudio.enable = false; - security.rtkit.enable = true; - services.pipewire = { - enable = true; - alsa.enable = true; - alsa.support32Bit = true; - pulse.enable = true; - # If you want to use JACK applications, uncomment this - #jack.enable = true; - - # use the example session manager (no others are packaged yet so this is enabled by default, - # no need to redefine it in your config for now) - #media-session.enable = true; - }; - - # Enable touchpad support (enabled default in most desktopManager). - # services.xserver.libinput.enable = true; - - # Define a user account. Don't forget to set a password with ‘passwd’. - users.users.finn = { - isNormalUser = true; - description = "Finn Markwitz"; - extraGroups = [ "networkmanager" "wheel" ]; - packages = with pkgs; [ - firefox - jetbrains.webstorm - jetbrains.goland - jetbrains.pycharm-professional - jetbrains.idea-ultimate - thunderbird - google-chrome - discord - spotify - keepassxc - nextcloud-client - zsh - oh-my-zsh - neovim - ]; - }; - - # Enable automatic login for the user. - services.xserver.displayManager.autoLogin.enable = true; - services.xserver.displayManager.autoLogin.user = "finn"; - - # Workaround for GNOME autologin: https://github.com/NixOS/nixpkgs/issues/103746#issuecomment-945091229 - systemd.services."getty@tty1".enable = false; - systemd.services."autovt@tty1".enable = false; - - # Allow unfree packages - nixpkgs.config.allowUnfree = true; - - # List packages installed in system profile. To search, run: - # $ nix search wget - environment.systemPackages = with pkgs; [ - vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default. - wget - git - python312 - nodejs_18 + customModules = import ./core/default.nix; + baseModules = [ + # make flake inputs accessible in NixOS + { + _module.args.self = self; + _module.args.inputs = self.inputs; + } + { + imports = [ + ({ pkgs, ... }: { + nixpkgs.overlays = [ + overlay-unstable + (import ../pkgs) + ]; + nix.nixPath = [ + "nixpkgs=${pkgs.path}" + ]; + documentation.info.enable = false; + }) + ]; + } + ../modules + # ../profiles ]; - - # Some programs need SUID wrappers, can be configured further or are - # started in user sessions. - # programs.mtr.enable = true; - # programs.gnupg.agent = { - # enable = true; - # enableSSHSupport = true; - # }; - - # List services that you want to enable: - - # Enable the OpenSSH daemon. - # services.openssh.enable = true; - - # Open ports in the firewall. - # networking.firewall.allowedTCPPorts = [ ... ]; - # networking.firewall.allowedUDPPorts = [ ... ]; - # Or disable the firewall altogether. - # networking.firewall.enable = false; - - # 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.05"; # Did you read the comment? - -} + defaultModules = baseModules ++ customModules; +in +{ + flake.nixosConfigurations = { + # use your hardware- model from this list: https://github.com/NixOS/nixos-hardware/blob/master/flake.nix + jupiter = nixosSystem { + system = "x86_64-linux"; + modules = defaultModules ++ [ + # nixos-hardware.nixosModules.bmax-b7-power + ./jupiter/configuration.nix + ]; + }; + }; +} \ No newline at end of file diff --git a/machines/configuration_old.nix b/machines/configuration_old.nix new file mode 100644 index 0000000..2ebb3b6 --- /dev/null +++ b/machines/configuration_old.nix @@ -0,0 +1,156 @@ +# 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, ... }: + +{ + imports = + [ # Include the results of the hardware scan. + ./hardware-configuration.nix + ]; + + # Bootloader. + boot.loader.grub.enable = true; + boot.loader.grub.device = "/dev/sda"; + boot.loader.grub.useOSProber = true; + + networking.hostName = "nixos"; # Define your hostname. + # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. + + # 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; + + # Set your time zone. + time.timeZone = "Europe/Berlin"; + + # Select internationalisation properties. + i18n.defaultLocale = "en_US.UTF-8"; + + i18n.extraLocaleSettings = { + LC_ADDRESS = "de_DE.UTF-8"; + LC_IDENTIFICATION = "de_DE.UTF-8"; + LC_MEASUREMENT = "de_DE.UTF-8"; + LC_MONETARY = "de_DE.UTF-8"; + LC_NAME = "de_DE.UTF-8"; + LC_NUMERIC = "de_DE.UTF-8"; + LC_PAPER = "de_DE.UTF-8"; + LC_TELEPHONE = "de_DE.UTF-8"; + LC_TIME = "de_DE.UTF-8"; + }; + + # Enable the X11 windowing system. + services.xserver.enable = true; + + # Enable the GNOME Desktop Environment. + services.xserver.displayManager.gdm.enable = true; + services.xserver.desktopManager.gnome.enable = true; + + # Configure keymap in X11 + services.xserver = { + layout = "de"; + xkbVariant = ""; + }; + + # Configure console keymap + console.keyMap = "de"; + + # Enable CUPS to print documents. + services.printing.enable = true; + + # Enable sound with pipewire. + sound.enable = true; + hardware.pulseaudio.enable = false; + security.rtkit.enable = true; + services.pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + # If you want to use JACK applications, uncomment this + #jack.enable = true; + + # use the example session manager (no others are packaged yet so this is enabled by default, + # no need to redefine it in your config for now) + #media-session.enable = true; + }; + + # Enable touchpad support (enabled default in most desktopManager). + # services.xserver.libinput.enable = true; + + # Define a user account. Don't forget to set a password with ‘passwd’. + users.users.finn = { + isNormalUser = true; + description = "Finn Markwitz"; + extraGroups = [ "networkmanager" "wheel" ]; + packages = with pkgs; [ + firefox + jetbrains.webstorm + jetbrains.goland + jetbrains.pycharm-professional + jetbrains.idea-ultimate + thunderbird + google-chrome + discord + spotify + keepassxc + nextcloud-client + zsh + oh-my-zsh + neovim + ]; + }; + + # Enable automatic login for the user. + services.xserver.displayManager.autoLogin.enable = true; + services.xserver.displayManager.autoLogin.user = "finn"; + + # Workaround for GNOME autologin: https://github.com/NixOS/nixpkgs/issues/103746#issuecomment-945091229 + systemd.services."getty@tty1".enable = false; + systemd.services."autovt@tty1".enable = false; + + # Allow unfree packages + nixpkgs.config.allowUnfree = true; + + # List packages installed in system profile. To search, run: + # $ nix search wget + environment.systemPackages = with pkgs; [ + vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default. + wget + git + python312 + nodejs_18 + ]; + + # Some programs need SUID wrappers, can be configured further or are + # started in user sessions. + # programs.mtr.enable = true; + # programs.gnupg.agent = { + # enable = true; + # enableSSHSupport = true; + # }; + + # List services that you want to enable: + + # Enable the OpenSSH daemon. + # services.openssh.enable = true; + + # Open ports in the firewall. + # networking.firewall.allowedTCPPorts = [ ... ]; + # networking.firewall.allowedUDPPorts = [ ... ]; + # Or disable the firewall altogether. + # networking.firewall.enable = false; + + # 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.05"; # Did you read the comment? + +} diff --git a/machines/core/core.nix b/machines/core/core.nix new file mode 100644 index 0000000..db080a2 --- /dev/null +++ b/machines/core/core.nix @@ -0,0 +1,44 @@ +{ config, pkgs, lib, ... }: +{ + # Packages + environment.systemPackages = with pkgs; [ + bandwhich + bind # dig + borgbackup + cryptsetup + file + fzf + gettext + git + gitAndTools.delta + gnufdisk + gptfdisk + htop + jq + killall + lsof + mosh + multipath-tools # kpartx + mtr + nmap + nmon + ouch # de-/compress + pciutils + progress + pv + reptyr + rsync + screen + stress-ng + usbutils + tmux + vim + wget + whois + zip + unzip + ]; + + time.timeZone = "Europe/Berlin"; + services.timesyncd.enable = true; +} \ No newline at end of file diff --git a/machines/core/default.nix b/machines/core/default.nix new file mode 100644 index 0000000..882e680 --- /dev/null +++ b/machines/core/default.nix @@ -0,0 +1,7 @@ +[ + ./core.nix + ./modules.nix + ./network.nix + ./nix.nix + ./users.nix +] \ No newline at end of file diff --git a/machines/core/modules.nix b/machines/core/modules.nix new file mode 100644 index 0000000..9760f1b --- /dev/null +++ b/machines/core/modules.nix @@ -0,0 +1,3 @@ +# Generate via nix-generate +{ config, lib, pkgs, ... }: +{} \ No newline at end of file diff --git a/machines/core/network.nix b/machines/core/network.nix new file mode 100644 index 0000000..4277a34 --- /dev/null +++ b/machines/core/network.nix @@ -0,0 +1,15 @@ +{ config, lib, pkgs, ... }: + +{ + networking.networkmanager = { + enable = true; + + unmanaged = [ + "interface-name:br-*" # Ignore docker compose network bridges + "interface-name:docker?" # Ignore docker default bridge + "interface-name:veth*" # Ignore docker compose network devices + "interface-name:virbr?" # Ignore libvirt default bridge + ]; + }; + +} \ No newline at end of file diff --git a/machines/core/nix.nix b/machines/core/nix.nix new file mode 100644 index 0000000..3e4359a --- /dev/null +++ b/machines/core/nix.nix @@ -0,0 +1,27 @@ +{ config, lib, pkgs, inputs, ... }: +{ + nix = { + daemonCPUSchedPolicy = "idle"; + daemonIOSchedClass = "idle"; + + settings = { + auto-optimise-store = true; + }; + + gc = { + automatic = true; + options = "--delete-older-than 30d"; + }; + + extraOptions = '' + experimental-features = nix-command flakes + warn-dirty = false + ''; + + registry = { + nixpkgs.flake = inputs.nixpkgs; + unstable.flake = inputs.nixpkgs-unstable; + }; + }; + nixpkgs.config.allowUnfree = true; +} \ No newline at end of file diff --git a/machines/core/user.nix b/machines/core/user.nix new file mode 100644 index 0000000..644f11f --- /dev/null +++ b/machines/core/user.nix @@ -0,0 +1,27 @@ +{ config, pkgs, lib, ... }: +{ + + users.users.finn = { + isNormalUser = true; + home = "/home/finn"; + group = "finn"; + extraGroups = [ + "adbusers" # adb control + "audio" # sound control + "dialout" # serial-console + "docker" # usage of `docker` socket + "input" # mouse control + "libvirtd" # kvm control + "networkmanager" # wireless configuration + "podman" # usage of `podman` socket + "video" # screen control + "wheel" # `sudo` for the user. + ]; + + # openssh.authorizedKeys.keys = [ "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOFx6OLwL9MbkD3mnMsv+xrzZHN/rwCTgVs758SCLG0h finn@thinkman" ]; + }; + + users.groups.finn = { + gid = 1000; + }; +} \ No newline at end of file diff --git a/machines/jupiter/configuration.nix b/machines/jupiter/configuration.nix index e1923c7..cc0c801 100644 --- a/machines/jupiter/configuration.nix +++ b/machines/jupiter/configuration.nix @@ -1,114 +1,18 @@ -# 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, ... }: - +{ config, pkgs, lib, ... }: { - imports = - [ # Include the results of the hardware scan. - ./hardware-configuration.nix - ]; + imports = [ - # Use the GRUB 2 boot loader. - boot.loader.grub.enable = true; - # boot.loader.grub.efiSupport = true; - # boot.loader.grub.efiInstallAsRemovable = true; - # boot.loader.efi.efiSysMountPoint = "/boot/efi"; - # Define on which hard drive you want to install Grub. - # boot.loader.grub.device = "/dev/sda"; # or "nodev" for efi only + ./disks.nix + ./hardware-configuration.nix + ./environments.nix + # ./system.nix use docker here + ]; - # networking.hostName = "nixos"; # Define your hostname. - # Pick only one of the below networking options. - # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. - # networking.networkmanager.enable = true; # Easiest to use and most distros use this by default. - - # Set your time zone. - # time.timeZone = "Europe/Amsterdam"; - - # Configure network proxy if necessary - # networking.proxy.default = "http://user:password@proxy:port/"; - # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain"; - - # Select internationalisation properties. - # i18n.defaultLocale = "en_US.UTF-8"; - # console = { - # font = "Lat2-Terminus16"; - # keyMap = "us"; - # useXkbConfig = true; # use xkbOptions in tty. - # }; - - # Enable the X11 windowing system. - services.xserver.enable = true; + networking.hostName = "jupiter"; - # Enable the GNOME Desktop Environment. - services.xserver.displayManager.gdm.enable = true; - services.xserver.desktopManager.gnome.enable = true; - - - # Configure keymap in X11 - # services.xserver.layout = "us"; - # services.xserver.xkbOptions = "eurosign:e,caps:escape"; - - # Enable CUPS to print documents. - # services.printing.enable = true; - - # Enable sound. - # sound.enable = true; - # hardware.pulseaudio.enable = true; - - # Enable touchpad support (enabled default in most desktopManager). - # services.xserver.libinput.enable = true; - - # Define a user account. Don't forget to set a password with ‘passwd’. - # users.users.alice = { - # isNormalUser = true; - # extraGroups = [ "wheel" ]; # Enable ‘sudo’ for the user. - # packages = with pkgs; [ - # firefox - # tree - # ]; - # }; - - # List packages installed in system profile. To search, run: - # $ nix search wget - # environment.systemPackages = with pkgs; [ - # vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default. - # wget - # ]; - - # Some programs need SUID wrappers, can be configured further or are - # started in user sessions. - # programs.mtr.enable = true; - # programs.gnupg.agent = { - # enable = true; - # enableSSHSupport = true; - # }; - - # List services that you want to enable: - - # Enable the OpenSSH daemon. - # services.openssh.enable = true; - - # Open ports in the firewall. - # networking.firewall.allowedTCPPorts = [ ... ]; - # networking.firewall.allowedUDPPorts = [ ... ]; - # Or disable the firewall altogether. - # networking.firewall.enable = false; - - # Copy the NixOS configuration file and link it from the resulting system - # (/run/current-system/configuration.nix). This is useful in case you - # accidentally delete configuration.nix. - # system.copySystemConfiguration = true; - - # 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.05"; # Did you read the comment? - -} - + system = { + stateVersion = "23.05"; + autoUpgrade.enable = true; + }; +} \ No newline at end of file diff --git a/machines/jupiter/disks.nix b/machines/jupiter/disks.nix new file mode 100644 index 0000000..c6dd991 --- /dev/null +++ b/machines/jupiter/disks.nix @@ -0,0 +1,31 @@ +{ config, lib, pkgs, ... }: + +# CHECK THIS OUT: https://github.com/nix-community/disko its kinda better but felix does not support it + +{ + boot.initrd.luks.devices."luks-drive" = { + name = "luks-drive"; + device = "/dev/disk/by-partlabel/Crypt"; + preLVM = true; + allowDiscards = true; + }; + + fileSystems."/" = { + device = "/dev/disk/by-label/thinkman-root"; + fsType = "ext4"; + }; + + fileSystems."/boot" = { + device = "/dev/disk/by-label/thinkman-bo"; + fsType = "vfat"; + }; + + fileSystems."/home" = { + device = "/dev/disk/by-label/thinkman-home"; + fsType = "ext4"; + }; + + swapDevices = [{ + device = "/dev/disk/by-label/thinkman-swap"; + }]; +} \ No newline at end of file diff --git a/machines/jupiter/environments.nix b/machines/jupiter/environments.nix new file mode 100644 index 0000000..e69de29 diff --git a/machines/jupiter/hardware-configuration.nix b/machines/jupiter/hardware-configuration_old.nix similarity index 100% rename from machines/jupiter/hardware-configuration.nix rename to machines/jupiter/hardware-configuration_old.nix diff --git a/machines/pkgs/default.nix b/machines/pkgs/default.nix new file mode 100644 index 0000000..7a11111 --- /dev/null +++ b/machines/pkgs/default.nix @@ -0,0 +1,4 @@ +final: prev: +{ + # homer = final.callPackage ./homer { }; +} \ No newline at end of file diff --git a/modules/default.nix b/modules/default.nix new file mode 100644 index 0000000..222f282 --- /dev/null +++ b/modules/default.nix @@ -0,0 +1,5 @@ +{ ... }: +{ + imports = [ + ]; +} \ No newline at end of file diff --git a/modules/environments/hyprland/default.nix b/modules/environments/hyprland/default.nix new file mode 100644 index 0000000..5e7d026 --- /dev/null +++ b/modules/environments/hyprland/default.nix @@ -0,0 +1,18 @@ +{ config, lib, pkgs, ... }: +let + cfg = config.my.profiles.hyprland; + in { + + + + options.my.profiles.hyprland = with lib; { + enable = mkEnableOption "hyprland env"; + }; + + config = lib.mkIf cfg.enable { + programs.hyprland.enable = true; + + } + + +} \ No newline at end of file diff --git a/modules/environments/zsh/default.nix b/modules/environments/zsh/default.nix new file mode 100644 index 0000000..7828ab9 --- /dev/null +++ b/modules/environments/zsh/default.nix @@ -0,0 +1,19 @@ +{ config, lib, pkgs, ... }: +let + cfg = config.my.profiles.zsh; + in { + + + + options.my.profiles.zsh = with lib; { + enable = mkEnableOption "zsh env"; + }; + + config = lib.mkIf cfg.enable { + programs.zsh.enable = true; + programs.zsh.ohMyZsh.enable = true; + users.defaultUserShell = pkgs.zsh; + } + + +} \ No newline at end of file