diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | README.md | 19 | ||||
-rw-r--r-- | flake.lock | 117 | ||||
-rw-r--r-- | flake.nix | 58 | ||||
-rw-r--r-- | home-manager/home.nix | 6 | ||||
-rw-r--r-- | makefile | 2 | ||||
-rw-r--r-- | nixos/autologin.nix (renamed from autologin.nix) | 0 | ||||
-rw-r--r-- | nixos/configuration.nix (renamed from configuration.nix) | 79 | ||||
-rw-r--r-- | nixos/hardware-configuration.nix | 41 |
9 files changed, 262 insertions, 61 deletions
diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 577b0a0..0000000 --- a/.gitignore +++ /dev/null @@ -1 +0,0 @@ -hardware-configuration.nix @@ -1,3 +1,22 @@ # Jptrzy's nixos config +**This configuration is impure,** so don't expect it will work for you out of the box, without any modifications. +For sure you need disk partitioned like bellow and write disk ids into **hardware-configuration.nix** file. +``` +disk +|- boot +|- encrypted + |- swap + |- root +``` + +## Why flake.nix for nixos configuration +Read more on [this blog post](https://www.tweag.io/blog/2020-07-31-nixos-flakes). + +If you want to start your own configuration check out [this repo](https://github.com/Misterio77/nix-starter-configs). + ## Installation [Full Guide](https://qfpl.io/posts/installing-nixos) + +## TODO +Use more independent config by implementing [nixos-hardware module](https://github.com/NixOS/nixos-hardware) and +using a separate file for partition config. diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..98e73b5 --- /dev/null +++ b/flake.lock @@ -0,0 +1,117 @@ +{ + "nodes": { + "base16-schemes": { + "flake": false, + "locked": { + "lastModified": 1680729003, + "narHash": "sha256-M9LHTL24/W4oqgbYRkz0B2qpNrkefTs98pfj3MxIXnU=", + "owner": "tinted-theming", + "repo": "base16-schemes", + "rev": "dc048afa066287a719ddbab62b3e19e4b5110cf0", + "type": "github" + }, + "original": { + "owner": "tinted-theming", + "repo": "base16-schemes", + "type": "github" + } + }, + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1695108154, + "narHash": "sha256-gSg7UTVtls2yO9lKtP0yb66XBHT1Fx5qZSZbGMpSn2c=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "07682fff75d41f18327a871088d20af2710d4744", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "release-23.05", + "repo": "home-manager", + "type": "github" + } + }, + "nix-colors": { + "inputs": { + "base16-schemes": "base16-schemes", + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1682108218, + "narHash": "sha256-tMr7BbxualFQlN+XopS8rMMgf2XR9ZfRuwIZtjsWmfI=", + "owner": "misterio77", + "repo": "nix-colors", + "rev": "b92df8f5eb1fa20d8e09810c03c9dc0d94ef2820", + "type": "github" + }, + "original": { + "owner": "misterio77", + "repo": "nix-colors", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1694937365, + "narHash": "sha256-iHZSGrb9gVpZRR4B2ishUN/1LRKWtSHZNO37C8z1SmA=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "5d017a8822e0907fb96f7700a319f9fe2434de02", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-23.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1680397293, + "narHash": "sha256-wBpJ73+tJ8fZSWb4tzNbAVahC4HSo2QG3nICDy4ExBQ=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "b18d328214ca3c627d3cc3f51fd9d1397fdbcd7a", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "nixpkgs-unstable": { + "locked": { + "lastModified": 1694959747, + "narHash": "sha256-CXQ2MuledDVlVM5dLC4pB41cFlBWxRw4tCBsFrq3cRk=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "970a59bd19eff3752ce552935687100c46e820a5", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "home-manager": "home-manager", + "nix-colors": "nix-colors", + "nixpkgs": "nixpkgs", + "nixpkgs-unstable": "nixpkgs-unstable" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..344a8a1 --- /dev/null +++ b/flake.nix @@ -0,0 +1,58 @@ +{ + description = "Jptrzy's nixos config"; + + inputs = { + # Nixpkgs + nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05"; + nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable"; + + # Home manager + home-manager.url = "github:nix-community/home-manager/release-23.05"; + home-manager.inputs.nixpkgs.follows = "nixpkgs"; + + # Nix Colors + nix-colors.url = "github:misterio77/nix-colors"; + }; + + outputs = { + self, + nixpkgs, + home-manager, + ... + } @ inputs: let + inherit (self) outputs; + + username = "jp3"; + hostname = "x270"; + + system = "x86_64-linux"; + + pkgs = import nixpkgs { + inherit system; + }; + lib = nixpkgs.lib; + in { + #overlays = import ./overlays {inherit inputs;}; + + # NixOS configuration entrypoint + # Available through 'nixos-rebuild --flake .#your-hostname' + nixosConfigurations = { + ${hostname} = nixpkgs.lib.nixosSystem { + specialArgs = { inherit username hostname system inputs outputs; }; + modules = [ + ./nixos/configuration.nix + + home-manager.nixosModules.home-manager { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users.${username} = { + imports = [ ./home-manager/home.nix ]; + }; + home-manager.extraSpecialArgs = { inherit username; }; + } + ]; + }; + }; + + }; +} diff --git a/home-manager/home.nix b/home-manager/home.nix index 3141fdc..b46d8ba 100644 --- a/home-manager/home.nix +++ b/home-manager/home.nix @@ -1,4 +1,4 @@ -{ user, config, pkgs, lib, ... }: +{ username, pkgs, lib, ... }: let nvim-spell-pl-utf8-dict = builtins.fetchurl { @@ -6,8 +6,8 @@ let sha256 = "1sg7hnjkvhilvh0sidjw5ciih0vdia9vas8vfrd9vxnk9ij51khl"; }; in { - home.username = "${user}"; - home.homeDirectory = "/home/${user}"; + home.username = "${username}"; + home.homeDirectory = "/home/${username}"; home.stateVersion = "22.05"; # Please read the comment before changing. diff --git a/makefile b/makefile new file mode 100644 index 0000000..62d98a4 --- /dev/null +++ b/makefile @@ -0,0 +1,2 @@ +sync: + sudo nixos-rebuild switch --flake .#x270 --show-trace --impure diff --git a/autologin.nix b/nixos/autologin.nix index 42a3316..42a3316 100644 --- a/autologin.nix +++ b/nixos/autologin.nix diff --git a/configuration.nix b/nixos/configuration.nix index 9c83935..3d1dfb6 100644 --- a/configuration.nix +++ b/nixos/configuration.nix @@ -2,13 +2,9 @@ # 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, username, config, pkgs, ... }: let - user = "jp3"; - - home-manager = builtins.fetchTarball "https://github.com/nix-community/home-manager/archive/release-23.05.tar.gz"; - dmenu-src = builtins.fetchTarball "https://git.jptrzy.xyz/dmenu/snapshot/master.tar.gz"; #dwm-src = builtins.fetchTarball "https://git.jptrzy.xyz/dwm/snapshot/master.tar.gz"; dwmblocks-src = builtins.fetchTarball "https://git.jptrzy.xyz/dwmblocks/snapshot/master.tar.gz"; @@ -16,13 +12,8 @@ let sent-src = builtins.fetchTarball "https://git.jptrzy.xyz/sent/snapshot/master.tar.gz"; slock-src = builtins.fetchTarball "https://git.jptrzy.xyz/slock/snapshot/master.tar.gz"; - dwm-src = /home/${user}/.local/src/dwm; + dwm-src = /home/${username}/.local/src/dwm; in { - -# NixOS Specific - # Copy the NixOS configuration - /run/current-system/configuration.nix - system.copySystemConfiguration = true; - # Check out https://nixos.org/nixos/options.html). system.stateVersion = "23.05"; # Did you read the comment? nixpkgs.config.allowUnfree = true; @@ -33,8 +24,6 @@ in { nix.gc.automatic = true; imports = [ - (import "${home-manager}/nixos") - # Include the results of the hardware scan. ./hardware-configuration.nix @@ -53,11 +42,7 @@ in { }; }; - home-manager.users."${user}" = import ./home-manager/home.nix { - inherit user config pkgs; - inherit (pkgs) lib; - }; - security.pam.services."${user}".enableGnomeKeyring = true; + security.pam.services."${username}".enableGnomeKeyring = true; security.wrappers = { slock = { owner = "root"; group = "root"; @@ -69,14 +54,16 @@ in { # BootLoader boot = { - initrd.luks.devices = { # Decrypt LUKS Partition before accessing LVM(s) partitions + # Decrypt LUKS Partition before accessing LVM(s) partitions + initrd.luks.devices = { root = { device = "/dev/sda2"; preLVM = true; }; }; - loader = { # Use the systemd-boot EFI boot loader. + # Use the systemd-boot EFI boot loader. + loader = { systemd-boot = { enable = true; configurationLimit = 3; @@ -91,21 +78,21 @@ in { # Set your time zone. time.timeZone = "Europe/Warsaw"; - users.groups."${user}" = {}; + users.groups."${username}" = {}; # Define a user account. Don't forget to set a password with ‘passwd’. - users.users."${user}" = { + users.users."${username}" = { createHome = true; isNormalUser = true; - extraGroups = [ "${user}" "wheel" "video" "audio" "disk" "networkmanager" ]; # Enable ‘sudo’ for the user. + extraGroups = [ "${username}" "wheel" "video" "audio" "disk" "networkmanager" ]; # Enable ‘sudo’ for the user. group = "users"; - home = "/home/${user}"; + home = "/home/${username}"; uid = 1000; }; # Network networking = { - hostName = "jp3-x270"; # Define your hostname. + hostName = "${hostname}"; # Define your hostname. networkmanager.enable = true; # Easiest to use and most distros use this by default. }; @@ -167,14 +154,13 @@ in { }; }; - printing = { - enable = true; - - drivers = [ - pkgs.hplip - pkgs.hplipWithPlugin - ]; - }; + #printing = { + # enable = true; + # drivers = [ + # pkgs.hplip + # pkgs.hplipWithPlugin + # ]; + #}; avahi = { enable = true; @@ -191,27 +177,6 @@ in { dbus.enable = true; }; -# Lock on lid close - #systemd.user.services.systemd-lock-handler = { - # enable = true; - #}; - - #systemd.services.xautolock-lid-close = { - # enable = true; - # description = "Enable xautolock on lid close"; - - # before = [ "sleep.target" ]; - # wantedBy = [ "sleep.target" ]; - - # serviceConfig = { - # Type = "forking"; - # User = "root"; - # Environment = "DISPLAY=:1"; - # ExecStartPre = "${pkgs.xorg.xhost}/bin/xhost si:localuser:root"; - # ExecStart = "${pkgs.xautolock}/bin/xautolock --locknow"; - # }; - #}; - # Services # PinEntry for GnuPG @@ -336,9 +301,9 @@ in { nil nix-index # Games - angband - nethack - openttd + #angband + #nethack + #openttd dolphin-emu ]; } diff --git a/nixos/hardware-configuration.nix b/nixos/hardware-configuration.nix new file mode 100644 index 0000000..ef908ea --- /dev/null +++ b/nixos/hardware-configuration.nix @@ -0,0 +1,41 @@ +# 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" "ahci" "usb_storage" "sd_mod" "rtsx_pci_sdmmc" ]; + boot.initrd.kernelModules = [ "dm-snapshot" ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/ff088d99-9fdc-4013-8082-008148360c14"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/091D-7160"; + fsType = "vfat"; + }; + + swapDevices = + [ { device = "/dev/disk/by-uuid/1135c8e4-787d-4643-ac13-64c454d7a6cd"; } + ]; + + # 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.<interface>.useDHCP`. + networking.useDHCP = lib.mkDefault true; + # networking.interfaces.enp0s31f6.useDHCP = lib.mkDefault true; + # networking.interfaces.wlp3s0.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + powerManagement.cpuFreqGovernor = lib.mkDefault "powersave"; + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} |