diff --git a/nix/build.sh b/nix/build.sh new file mode 100644 index 0000000..aee0bb9 --- /dev/null +++ b/nix/build.sh @@ -0,0 +1,16 @@ +#! /bin/sh + +install_home_manager() { + nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager + nix-channel --update + + export NIX_PATH=$HOME/.nix-defexpr/channels${NIX_PATH:+:}$NIX_PATH + nix-shell '' -A install +} + +build_system() { + sudo nix-channel --add https://nixos.org/channels/nixos-unstable nixos + sudo cp system/configuration.nix /etc/nixos/ + + sudo nixos-rebuild switch --upgrade +} diff --git a/nix/home/commandline.nix b/nix/home/commandline.nix new file mode 100644 index 0000000..048af40 --- /dev/null +++ b/nix/home/commandline.nix @@ -0,0 +1,14 @@ +{ pkgs, ... }: + +let + defaultPkgs = with pkgs; [ + lorri + p7zip + ]; +in +{ + imports = [(import ./universal.nix)]; + + services.lorri.enable = true; + xdg.enable = true; +} diff --git a/nix/home/desktop.nix b/nix/home/desktop.nix new file mode 100644 index 0000000..77e537c --- /dev/null +++ b/nix/home/desktop.nix @@ -0,0 +1,22 @@ +{ pkgs, ... }: + +let + defaultPkgs = with pkgs; [ + calibre + dmenu + firefox + gnomecast + multilockscreen + signal-desktop + slack + vlc + zathura + ]; +in +{ + imports = [(import ./commandline.nix)] ++ [(import ./programs/rofi)]; + + home = { + packages = defaultPkgs; + }; +} diff --git a/nix/home/programs/direnv/default.nix b/nix/home/programs/direnv/default.nix new file mode 100644 index 0000000..8fedccb --- /dev/null +++ b/nix/home/programs/direnv/default.nix @@ -0,0 +1,9 @@ +{pkgs, ...}: +let +in with builtins; +{ + programs.direnv = { + enable = true; + stdlib = readFile ./direnvrc; + }; +} diff --git a/nix/direnv/direnvrc b/nix/home/programs/direnv/direnvrc similarity index 100% rename from nix/direnv/direnvrc rename to nix/home/programs/direnv/direnvrc diff --git a/nix/home/programs/git/default.nix b/nix/home/programs/git/default.nix new file mode 100644 index 0000000..51ee80d --- /dev/null +++ b/nix/home/programs/git/default.nix @@ -0,0 +1,22 @@ +{ pkgs, ... }: + +let +in + { + programs.git = { + enable = true; + userName = "Haak Saxberg"; + userEmail = "haak.erling@gmail.com"; + ignores = [ + ".idea/" + ".direnv/" + ".git-plans/" + ".envrc" + ".tools-info" + "*~" + "*.swp" + ".yardoc/" + "doc/" + ]; + }; +} diff --git a/nix/home.nix b/nix/home/programs/nvim/default.nix similarity index 62% rename from nix/home.nix rename to nix/home/programs/nvim/default.nix index d975660..a35a369 100644 --- a/nix/home.nix +++ b/nix/home/programs/nvim/default.nix @@ -1,23 +1,5 @@ -{ config, lib, pkgs, ... }: - -with lib; - +{ pkgs, ... }: let - git-plan = pkgs.rustPlatform.buildRustPackage rec { - name = "git-plan"; - version = "1"; - src = pkgs.fetchFromGitLab { - owner = "haaksmash"; - repo = "git-plan"; - rev = "518dcf15f3a46605f18569dd69b3b63d763e9439"; - sha256 = "06gh3v35bdr0qsp459183br4hpmwm36d2r9fjyx9j5jfpzggqg51"; - }; - - cargoSha256 = "17lr4pc2fjcgvx0p4vpkwx3mg9jadb4lygbwri0blmnkqql8xlh3"; - nativeBuildInputs = [ pkgs.pkgconfig ]; - buildInputs = [ pkgs.openssl ] ++ (if pkgs.stdenv.isDarwin then [ pkgs.libiconv pkgs.darwin.apple_sdk.frameworks.Security ] else []); - }; - vim-goyo = pkgs.vimUtils.buildVimPlugin { name = "vim-goyo"; src = pkgs.fetchFromGitHub { @@ -47,89 +29,8 @@ let sha256 = "0i0p21jkrx99n3dnm5xvnw8n963c67l4lgl4iwngz0psdzwxphkw"; }; }; -in +in with builtins; { - home.packages = with pkgs; [ - git-plan - htop - jq - keybase - lastpass-cli - lorri - nnn - tree - ripgrep - zsh-autosuggestions - zsh-history-substring-search - zsh-syntax-highlighting - ]; - - programs.direnv = { - enable = true; - stdlib = readFile ./direnv/direnvrc; - }; - - programs.git = { - enable = true; - userName = "Haak Saxberg"; - userEmail = "haak.erling@gmail.com"; - ignores = [ - ".idea/" - ".direnv/" - ".git-plans/" - ".envrc" - ".tools-info" - "*~" - "*.swp" - ".yardoc/" - "doc/" - ]; - }; - - programs.zsh = { - enable = true; - enableCompletion = true; - defaultKeymap = "viins"; - - initExtra = readFile ./zsh/zshrc; - - oh-my-zsh = { - enable = true; - theme = "typewritten"; - custom = "$HOME/.oh-my-zsh/custom"; - plugins = [ - "vi-mode" - "git" - "z" - ]; - }; - }; - - programs.kakoune = { - enable = true; - config = { - numberLines = { - enable = true; - highlightCursor = true; - relative = true; - }; - }; - - plugins = with pkgs.kakounePlugins; [ - kak-prelude - kak-fzf - kak-auto-pairs - kak-ansi - ]; - - extraConfig = '' - colorscheme tomorrow-night - set -add global autoinfo normal - # FZF settings - map global normal ': fzf-mode' - ''; - }; - programs.neovim = { enable = true; vimAlias = true; @@ -218,7 +119,7 @@ in lua << EOF ${readFile ( pkgs.substituteAll { - src = ./vim/nvim-lspconfig.lua; + src = ./nvim-lspconfig.lua; # since both of these are used for actually configuring the system, # we'll probably always want them around. lua_ls = pkgs.sumneko-lua-language-server; @@ -239,33 +140,7 @@ in } ]; - extraConfig = readFile ./vim/init.vim; + extraConfig = readFile ./init.vim; }; - programs.tmux = { - enable = true; - tmuxinator = { - enable = true; - }; - secureSocket = false; - }; - - programs.fzf = { - enable = true; - enableZshIntegration = true; - defaultCommand = "rg --no-ignore --follow --files --hidden --smart-case --glob \\\"!.git/*\\\""; - }; - - # services.lorri.enable = !pkgs.stdenv.isDarwin; - - # Let Home Manager install and manage itself. - programs.home-manager.enable = true; - - home.file.".tmux.conf" = { - source = ./tmux/tmux.conf; - }; - - home.file.".oh-my-zsh/custom/themes/typewritten.zsh-theme" = { - source = ./zsh/typewritten.zsh-theme; - }; } diff --git a/nix/vim/init.vim b/nix/home/programs/nvim/init.vim similarity index 100% rename from nix/vim/init.vim rename to nix/home/programs/nvim/init.vim diff --git a/nix/vim/nvim-lspconfig.lua b/nix/home/programs/nvim/nvim-lspconfig.lua similarity index 100% rename from nix/vim/nvim-lspconfig.lua rename to nix/home/programs/nvim/nvim-lspconfig.lua diff --git a/nix/obsidian.nix b/nix/home/programs/obsidianmd/default.nix similarity index 100% rename from nix/obsidian.nix rename to nix/home/programs/obsidianmd/default.nix diff --git a/nix/home/programs/rofi/default.nix b/nix/home/programs/rofi/default.nix new file mode 100644 index 0000000..de785b1 --- /dev/null +++ b/nix/home/programs/rofi/default.nix @@ -0,0 +1,7 @@ +{ pkgs, ... }: + +{ + programs.rofi = { + enable = true; + }; +} diff --git a/nix/home/programs/tmux/default.nix b/nix/home/programs/tmux/default.nix new file mode 100644 index 0000000..63a195d --- /dev/null +++ b/nix/home/programs/tmux/default.nix @@ -0,0 +1,14 @@ +{ pkgs, ... }: +{ + programs.tmux = { + enable = true; + tmuxinator = { + enable = true; + }; + secureSocket = false; + }; + + home.file.".tmux.conf" = { + source = ./tmux.conf; + }; +} diff --git a/nix/tmux/tmux.conf b/nix/home/programs/tmux/tmux.conf similarity index 100% rename from nix/tmux/tmux.conf rename to nix/home/programs/tmux/tmux.conf diff --git a/nix/home/programs/zsh/default.nix b/nix/home/programs/zsh/default.nix new file mode 100644 index 0000000..636bef1 --- /dev/null +++ b/nix/home/programs/zsh/default.nix @@ -0,0 +1,27 @@ +{ pkgs, ... }: + +with builtins; { + + programs.zsh = { + enable = true; + enableCompletion = true; + defaultKeymap = "viins"; + + initExtra = readFile ./zshrc; + + oh-my-zsh = { + enable = true; + theme = "typewritten"; + custom = "$HOME/.oh-my-zsh/custom"; + plugins = [ + "vi-mode" + "git" + "z" + ]; + }; + }; + + home.file.".oh-my-zsh/custom/themes/typewritten.zsh-theme" = { + source = ./typewritten.zsh-theme; + }; +} diff --git a/nix/zsh/typewritten.zsh-theme b/nix/home/programs/zsh/typewritten.zsh-theme similarity index 100% rename from nix/zsh/typewritten.zsh-theme rename to nix/home/programs/zsh/typewritten.zsh-theme diff --git a/nix/zsh/zshrc b/nix/home/programs/zsh/zshrc similarity index 100% rename from nix/zsh/zshrc rename to nix/home/programs/zsh/zshrc diff --git a/nix/home/universal.nix b/nix/home/universal.nix new file mode 100644 index 0000000..8f16aac --- /dev/null +++ b/nix/home/universal.nix @@ -0,0 +1,58 @@ +{ pkgs, ... }: + +let + git-plan = pkgs.rustPlatform.buildRustPackage rec { + name = "git-plan"; + version = "1"; + src = pkgs.fetchFromGitLab { + owner = "haaksmash"; + repo = "git-plan"; + rev = "518dcf15f3a46605f18569dd69b3b63d763e9439"; + sha256 = "06gh3v35bdr0qsp459183br4hpmwm36d2r9fjyx9j5jfpzggqg51"; + }; + + cargoSha256 = "17lr4pc2fjcgvx0p4vpkwx3mg9jadb4lygbwri0blmnkqql8xlh3"; + nativeBuildInputs = [ pkgs.pkgconfig ]; + buildInputs = [ pkgs.openssl ] ++ (if pkgs.stdenv.isDarwin then [ pkgs.libiconv pkgs.darwin.apple_sdk.frameworks.Security ] else []); + }; + + defaultPkgs = with pkgs; [ + git-plan + jq + nnn + tree + ripgrep + zsh-autosuggestions + zsh-history-substring-search + zsh-syntax-highlighting + ]; +in with builtins; +{ + # Let Home Manager install and manage itself. + programs.home-manager.enable = true; + # no need for home-manager news, thanks + news.display = "silent"; + + nixpkgs.config = { + allowUnfree = true; + }; + + imports = [ + (import ./programs/direnv) + (import ./programs/git) + (import ./programs/zsh) + (import ./programs/tmux) + (import ./programs/nvim) + ]; + + programs.htop = { + enable = true; + }; + + programs.fzf = { + enable = true; + enableZshIntegration = true; + defaultCommand = "rg --no-ignore --follow --files --hidden --smart-case --glob \\\"!.git/*\\\""; + }; + +} diff --git a/nix/system/configuration.nix b/nix/system/configuration.nix new file mode 100644 index 0000000..c96b9bb --- /dev/null +++ b/nix/system/configuration.nix @@ -0,0 +1,164 @@ +# 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. + /etc/nixos/hardware-configuration.nix + ]; + + # Use the systemd-boot EFI boot loader. + boot.loader.systemd-boot.enable = true; + # do not fill the bootloader space with generations until it pops; only keep + # a reasonable number around. + boot.loader.systemd-boot.configurationLimit = 42; + # WiFi support requires kernel 5.13 + boot.kernelPackages = pkgs.linuxPackages_latest; + boot.loader.efi.canTouchEfiVariables = true; + + hardware.bluetooth.enable = true; + networking.hostName = "framework"; # Define your hostname. + networking.networkmanager.enable = true; + # Create entries for /etc/wpa_supplicant.conf by running `wpa_passphrase SSID PASSWORD` + # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. + + # The global useDHCP flag is deprecated, therefore explicitly set to false here. + # Per-interface useDHCP will be mandatory in the future, so this generated config + # replicates the default behaviour. + networking.useDHCP = false; + networking.interfaces.wlp170s0.useDHCP = true; + + # 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"; + }; + + + # Set your time zone. + time.timeZone = "America/Los_Angeles"; + + # List packages installed in system profile. To search, run: + # $ nix search wget + environment.systemPackages = with pkgs; [ + cachix + vim + wget + zsh + ]; + + nixpkgs.config.allowUnfree = true; + + # Open ports in the firewall. + networking.firewall = { + allowedTCPPorts = [ + 631 # CUPs port for printing + ]; + allowedUDPPorts = [ + 631 + ]; + }; + # Or disable the firewall altogether. + # networking.firewall.enable = false; + + + # 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 fingerprint reading + services.fprintd.enable = true; + + # Enable the OpenSSH daemon. + # services.openssh.enable = true; + + # Enable CUPS to print documents. + services.printing = { + enable = true; + drivers = [ pkgs.hplip ]; + }; + # enable avahi for printer discovery + services.avahi = { + enable = true; + nssmdns = true; + }; + + # Enable sound. + sound.enable = true; + hardware.pulseaudio = { + enable = true; + # The full package is necessary to allow bluetooth audio devices. + package = pkgs.pulseaudioFull; + }; + + + # Enable touchpad support. + services.xserver.libinput.enable = true; + + services.xserver = { + # Enable the X11 windowing system. + enable = true; + + # Enable the GNOME Desktop Environment. + desktopManager.gnome.enable = true; + displayManager = { + defaultSession = "none+xmonad"; + }; + + windowManager.xmonad = { + enable = true; + enableContribAndExtras = true; + }; + + layout = "us"; + # run the following command to swap escape and caps-lock keys, like a + # civilized person: + xkbOptions = "caps:swapescape"; + }; + + services.syncthing = { + enable = true; + user = "haak"; + dataDir = "/home/haak/synced"; + configDir = "/home/haak/synced/.config/syncthing"; + }; + + location.provider = "geoclue2"; + + # Define a user account. Don't forget to set a password with ‘passwd’. + users.users.haak = { + isNormalUser = true; + extraGroups = [ + "wheel" # Enable ‘sudo’ for the user. + "networkmanager" # Allow the user to manage networks + ]; + }; + + users.extraUsers.haak = { + shell = pkgs.zsh; + }; + + nix.trustedUsers = [ "root" "haak" ]; + + # This value determines the NixOS release with which your system is to be + # compatible, in order to avoid breaking some software such as database + # servers. You should change this only after NixOS release notes say you + # should. + system.stateVersion = "21.05"; # Did you read the comment? + system.autoUpgrade.enable = true; +} + + diff --git a/nix/darwin-configuration.nix b/nix/system/darwin-configuration.nix similarity index 100% rename from nix/darwin-configuration.nix rename to nix/system/darwin-configuration.nix diff --git a/nix/system/xmonad.nix b/nix/system/xmonad.nix new file mode 100644 index 0000000..98693b5 --- /dev/null +++ b/nix/system/xmonad.nix @@ -0,0 +1,12 @@ +{ config, lib, pkgs, ...}: + +{ + displayManager = { + defaultSession = "none+xmonad"; + }; + + windowManager.xmonad = { + enable = true; + enableContribAndExtras = true; + }; +}