From 1b2733c02a2e8ee6d697db3b7c88890e684563b4 Mon Sep 17 00:00:00 2001 From: hheik <4469778+hheik@users.noreply.github.com> Date: Sat, 23 Sep 2023 17:34:03 +0300 Subject: [PATCH] Initial commit --- .gitignore | 2 + configuration.nix | 107 +++++++++++++++++++++++++++++++++++++++++++ flake.lock | 66 ++++++++++++++++++++++++++ flake.nix | 38 +++++++++++++++ home.nix | 75 ++++++++++++++++++++++++++++++ overlays/default.nix | 9 ++++ 6 files changed, 297 insertions(+) create mode 100644 .gitignore create mode 100644 configuration.nix create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 home.nix create mode 100644 overlays/default.nix diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..24920df --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +hardware-configuration.nix +*.swp diff --git a/configuration.nix b/configuration.nix new file mode 100644 index 0000000..e559246 --- /dev/null +++ b/configuration.nix @@ -0,0 +1,107 @@ +# System configuration + +{ config, pkgs, ... }: +{ + virtualisation.vmVariant = { + # following configuration is added only when building VM with build-vm + virtualisation = { + memorySize = 4096; + cores = 4; + }; + + # Enable the OpenSSH daemon. + services.openssh.enable = true; + networking.firewall.enable = false; + }; + + imports = [ + ./hardware-configuration.nix + ]; + + users.users.hheikkinen.isNormalUser = true; + users.users.hheikkinen.extraGroups = [ "networkmanager" "wheel" ]; + users.users.hheikkinen.initialPassword = "password"; + + boot.loader.systemd-boot.enable = false; + boot.loader.efi.canTouchEfiVariables = true; + boot.loader.grub = { + device = "nodev"; + useOSProber = false; + efiSupport = true; + }; + + hardware.opengl.enable = true; + + networking.hostName = "nixos"; + # 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. + + programs.nm-applet.enable = true; + + time.timeZone = "Europe/Helsinki"; + + # Select internationalisation properties. + i18n.defaultLocale = "en_US.UTF-8"; + + i18n.extraLocaleSettings = { + LC_ADDRESS = "fi_FI.UTF-8"; + LC_IDENTIFICATION = "fi_FI.UTF-8"; + LC_MEASUREMENT = "fi_FI.UTF-8"; + LC_MONETARY = "fi_FI.UTF-8"; + LC_NAME = "fi_FI.UTF-8"; + LC_NUMERIC = "fi_FI.UTF-8"; + LC_PAPER = "fi_FI.UTF-8"; + LC_TELEPHONE = "fi_FI.UTF-8"; + LC_TIME = "fi_FI.UTF-8"; + }; + + fonts.fonts = with pkgs; [ + envypn-font + nerdfonts + ]; + + console = { + font = "envypn 11"; + #keyMap = "us"; + useXkbConfig = true; # use xkbOptions in tty. + }; + + # Enable the X11 windowing system + services.xserver.enable = true; + services.xserver = { + displayManager.defaultSession = "none+i3"; + displayManager.lightdm.enable = true; + displayManager.autoLogin.enable = false; + displayManager.autoLogin.user = "hheikkinen"; + windowManager.i3.enable = true; + layout = "us"; + xkbVariant = ""; + videoDrivers = [ "nvidia" ]; + }; + + sound.enable = true; + hardware.pulseaudio.enable = true; + + nixpkgs.config.allowUnfree = true; + + environment.systemPackages = with pkgs; [ + neovim + wget + curl + w3m + ly + git + ranger + openssl + xorg.xwininfo + ]; + + # 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/flake.lock b/flake.lock new file mode 100644 index 0000000..458b41b --- /dev/null +++ b/flake.lock @@ -0,0 +1,66 @@ +{ + "nodes": { + "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" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1695272228, + "narHash": "sha256-4uw2OdJPVyjdB+xcDst9SecrNIpxKXJ2usN3M5HVa7o=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "55ac2a9d2024f15c56adf20da505b29659911da8", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-23.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-unstable": { + "locked": { + "lastModified": 1695145219, + "narHash": "sha256-Eoe9IHbvmo5wEDeJXKFOpKUwxYJIOxKUesounVccNYk=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "5ba549eafcf3e33405e5f66decd1a72356632b96", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "home-manager": "home-manager", + "nixpkgs": "nixpkgs", + "nixpkgs-unstable": "nixpkgs-unstable" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..833cdfd --- /dev/null +++ b/flake.nix @@ -0,0 +1,38 @@ +{ + description = "hheik NixOS configuration"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05"; + nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable"; + home-manager.url = "github:nix-community/home-manager/release-23.05"; + home-manager.inputs.nixpkgs.follows = "nixpkgs"; + }; + + outputs = inputs@{ self, nixpkgs, home-manager, ... }: + let + inherit (self) outputs; + in + rec { + overlays = import ./overlays { inherit inputs; }; + nixosConfigurations = { + nixos = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + ./configuration.nix + home-manager.nixosModules.home-manager + { + # Disable to allow user user packages + home-manager.useGlobalPkgs = false; + # Necessary to use `nixos-rebuild build-vm` + home-manager.useUserPackages = true; + home-manager.users.hheikkinen = import ./home.nix; + + # Optionally, use home-manager.extraSpecialArgs to pass + # arguments to home.nix + home-manager.extraSpecialArgs = { inherit inputs outputs; }; + } + ]; + }; + }; + }; +} diff --git a/home.nix b/home.nix new file mode 100644 index 0000000..0bd0823 --- /dev/null +++ b/home.nix @@ -0,0 +1,75 @@ +{ inputs, outputs, lib, config, pkgs, ... }: +{ + # You can import other home-manager modules here + imports = []; + + nixpkgs = { + overlays = [ + outputs.overlays.unstable-packages + ]; + config = { + allowUnfree = true; + # Workaround for https://github.com/nix-community/home-manager/issues/2942 + allowUnfreePredicate = (_: true); + }; + }; + + home = { + username = "hheikkinen"; + homeDirectory = "/home/hheikkinen"; + keyboard.layout = "us"; + packages = with pkgs; [ + brave + arandr + autorandr + cowsay + pavucontrol + keepassxc + yt-dlp + mpv + feh + rustup + neofetch + terminator + moc + ]; + }; + + programs = { + bash = { + enable = true; + enableCompletion = true; + shellAliases = { + bye = "(echo 'Press enter to confirm shutdown...'); read && shutdown 0"; + }; + historyControl = [ "ignorespace" ]; + historyFile = "$HOME/.bash_history"; + historyFileSize = 1000000; + bashrcExtra = '' +export PS1="\[\033[38;5;10m\]\u\[$(tput sgr0)\]\[\033[38;5;7m\]@\[$(tput sgr0)\]\[\033[38;5;14m\]\h\[$(tput sgr0)\]\[\033[38;5;7m\]:\[$(tput sgr0)\]\[\033[38;5;12m\]\w\[$(tput sgr0)\]\\$ \[$(tput sgr0)\]" + +export NIX_CONFIG='experimental-features = nix-command flakes' +[ -f "$HOME/.cargo/env" ] && . "$HOME/.cargo/env" + +export HISTTIMEFORMAT="[%F %T] " +export PROMPT_COMMAND="history -a; $PROMPT_COMMAND" + ''; + profileExtra = '' +[ -d "$HOME/.local/scripts" ] && PATH="$HOME/.local/scripts:$PATH" +[ -d "$HOME/.local/bin" ] && PATH="$HOME/.local/bin:$PATH" +[ -d "$HOME/.yarn/bin" ] && PATH="$HOME/.yarn/bin:$PATH" + ''; + }; + git = { + enable = true; + userName = "hheik"; + userEmail = "4469778+hheik@users.noreply.github.com"; + }; + }; + + programs.home-manager.enable = true; + systemd.user.startServices = "sd-switch"; + + # https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion + home.stateVersion = "23.05"; +} diff --git a/overlays/default.nix b/overlays/default.nix new file mode 100644 index 0000000..9ba6580 --- /dev/null +++ b/overlays/default.nix @@ -0,0 +1,9 @@ +{ inputs, ... }: +{ + unstable-packages = final: _prev: { + unstable = import inputs.nixpkgs-unstable { + system = final.system; + config.allowUnfree = true; + }; + }; +}