From f2f5227384bfe871587e5c5f9866d1c26d19be3d Mon Sep 17 00:00:00 2001 From: marc Date: Sun, 13 Nov 2022 17:46:29 +0100 Subject: [PATCH] First working doom emacs config --- README.org | 143 ++++++++++++++--------------- flake.lock | 17 ++++ flake.nix | 7 +- home/hosts/reykjavik.nix | 1 + home/modules/editors/default.nix | 1 + home/modules/editors/emacs.nix | 14 +++ system/hosts/reykjavik/default.nix | 1 + system/modules/editors/default.nix | 1 + system/modules/editors/emacs.nix | 119 ++++++++++++++++++++++++ system/profiles/common.nix | 2 +- 10 files changed, 232 insertions(+), 74 deletions(-) create mode 100644 home/modules/editors/emacs.nix create mode 100644 system/modules/editors/emacs.nix diff --git a/README.org b/README.org index 1fb58cb..a0e4318 100644 --- a/README.org +++ b/README.org @@ -3,91 +3,90 @@ ** Fresh system (nixos USB drive) 1. Open a nix-shell with git: -#+BEGIN_SRC bash -nix-shell -p git -#+END_SRC + #+BEGIN_SRC bash + nix-shell -p git + #+END_SRC -1. Clone the flake -#+BEGIN_SRC bash -git clone https://git.lajuntament.space/marc/samfelag.git -#+END_SRC +2. Clone the flake + #+BEGIN_SRC bash + git clone https://git.lajuntament.space/marc/samfelag.git + #+END_SRC -1. Partition the disk - 1. Locate the disk - #+BEGIN_SRC bash - lsblk - #+END_SRC +3. Partition the disk + 1. Locate the disk + #+BEGIN_SRC bash + lsblk + #+END_SRC - 1. Create a GPT partition table - #+BEGIN_SRC bash - sudo parted /dev/nvme0n1 -- mklabel gpt - #+END_SRC + 2. Create a GPT partition table + #+BEGIN_SRC bash + sudo parted /dev/nvme0n1 -- mklabel gpt + #+END_SRC - 1. Create the root partition - #+BEGIN_SRC bash - sudo parted /dev/nvme0n1 -- mkpart primary 512MB -8GB - #+END_SRC + 3. Create the root partition + #+BEGIN_SRC bash + sudo parted /dev/nvme0n1 -- mkpart primary 512MB -8GB + #+END_SRC - 1. Create the swap partition - #+BEGIN_SRC bash - sudo parted /dev/nvme0n1 -- mkpart primary linux-swap -8GB 100% - #+END_SRC + 4. Create the swap partition + #+BEGIN_SRC bash + sudo parted /dev/nvme0n1 -- mkpart primary linux-swap -8GB 100% + #+END_SRC - 1. Create the boot partition - #+BEGIN_SRC bash - sudo parted /dev/nvme0n1 -- mkpart ESP fat32 1MB 512MB - sudo parted /dev/nvme0n1 -- set 3 esp on - #+END_SRC + 5. Create the boot partition + #+BEGIN_SRC bash + sudo parted /dev/nvme0n1 -- mkpart ESP fat32 1MB 512MB + sudo parted /dev/nvme0n1 -- set 3 esp on + #+END_SRC -1. Format the partitions - 1. Root partition - #+BEGIN_SRC bash - sudo mkfs.ext4 -L nixos /dev/nvme0n1p1 - #+END_SRC +4. Format the partitions + 1. Root partition + #+BEGIN_SRC bash + sudo mkfs.ext4 -L nixos /dev/nvme0n1p1 + #+END_SRC - 1. Swap partition - #+BEGIN_SRC bash - sudo mkswap -L swap /dev/nvme0n1p2 - #+END_SRC + 2. Swap partition + #+BEGIN_SRC bash + sudo mkswap -L swap /dev/nvme0n1p2 + #+END_SRC - 1. Boot partition - #+BEGIN_SRC bash - sudo mkfs.fat -F 32 -n BOOT /dev/nvme0n1p3 - #+END_SRC + 3. Boot partition + #+BEGIN_SRC bash + sudo mkfs.fat -F 32 -n BOOT /dev/nvme0n1p3 + #+END_SRC -1. Mount the filesystems - 1. Root partition - #+BEGIN_SRC bash - sudo mount /dev/disk/by-label/nixos /mnt - #+END_SRC +5. Mount the filesystems + 1. Root partition + #+BEGIN_SRC bash + sudo mount /dev/disk/by-label/nixos /mnt + #+END_SRC - 1. Boot partition - #+BEGIN_SRC bash - sudo mkdir -p /mnt/boot - sudo mount /dev/disk/by-label/BOOT /mnt/boot - #+END_SRC + 2. Boot partition + #+BEGIN_SRC bash + sudo mkdir -p /mnt/boot + sudo mount /dev/disk/by-label/BOOT /mnt/boot + #+END_SRC - 1. Swap partition (if needed) - #+BEGIN_SRC bash - sudo swapon /dev/disk/by-label/swap - #+END_SRC + 3. Swap partition (if needed) + #+BEGIN_SRC bash + sudo swapon /dev/disk/by-label/swap + #+END_SRC -1. Create the host nix configuration -If the host is not present under system/hosts, create a new folder for the host. -Generate the hardware configuration file, you can use nixos-generate-config as a base: +6. Create the host nix configuration + If the host is not present under system/hosts, create a new folder for the host. + Generate the hardware configuration file, you can use nixos-generate-config as a base: -#+BEGIN_SRC bash -nixos-generate-config --dir <> --no-filesystems -#+END_SRC + #+BEGIN_SRC bash + nixos-generate-config --dir <> --no-filesystems + #+END_SRC -1. Install nixos! +7. Install nixos! + #+BEGIN_SRC bash + sudo nixos-install --impure --root /mnt --flake .#reykjavik + #+END_SRC -#+BEGIN_SRC bash -sudo nixos-install --impure --root /mnt --flake .#reykjavik -#+END_SRC - -1. Set up the user -You'll set the root password during the installation. You can then reboot and use the installed OS. First thing you'll have to do is log in as root and set the password for your user: -#+BEGIN_SRC bash -passwd marc -#+END_SRC +8. Set up the user + You'll set the root password during the installation. You can then reboot and use the installed OS. First thing you'll have to do is log in as root and set the password for your user: + #+BEGIN_SRC bash + passwd marc + #+END_SRC diff --git a/flake.lock b/flake.lock index 4b613cd..b1b33fb 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,21 @@ { "nodes": { + "doom-emacs": { + "flake": false, + "locked": { + "lastModified": 1667229496, + "narHash": "sha256-SURAFrtblyvkflQz1cEQogfo31UzSvKd+UOgczUyJ8k=", + "owner": "doomemacs", + "repo": "doomemacs", + "rev": "9d4d5b756a8598c4b5c842e9f1f33148af2af8fd", + "type": "github" + }, + "original": { + "owner": "doomemacs", + "repo": "doomemacs", + "type": "github" + } + }, "emacs-overlay": { "inputs": { "flake-utils": "flake-utils", @@ -87,6 +103,7 @@ }, "root": { "inputs": { + "doom-emacs": "doom-emacs", "emacs-overlay": "emacs-overlay", "home-manager": "home-manager", "nixpkgs": "nixpkgs_2" diff --git a/flake.nix b/flake.nix index 2480a25..16cf92c 100644 --- a/flake.nix +++ b/flake.nix @@ -10,9 +10,12 @@ emacs-overlay.url = "github:nix-community/emacs-overlay"; + doom-emacs.url = "github:doomemacs/doomemacs"; + doom-emacs.flake = false; + }; - outputs = { self, nixpkgs, home-manager, ... }: + outputs = inputs @ { self, nixpkgs, home-manager, ... }: let system = "x86_64-linux"; pkgs = import nixpkgs { @@ -53,6 +56,7 @@ reykjavik = lib.nixosSystem { inherit system; inherit pkgs; + specialArgs = { inherit inputs; }; modules = [ ./system/modules @@ -60,6 +64,7 @@ ./system/hosts/reykjavik home-manager.nixosModules.home-manager { + home-manager.extraSpecialArgs = { inherit inputs; }; home-manager.useGlobalPkgs = true; home-manager.useUserPackages = true; home-manager.users.marc = { diff --git a/home/hosts/reykjavik.nix b/home/hosts/reykjavik.nix index e0b72df..5e1cc7b 100644 --- a/home/hosts/reykjavik.nix +++ b/home/hosts/reykjavik.nix @@ -9,6 +9,7 @@ discord.enable = true; spotify.enable = true; }; + editors.emacs.enable = true; }; profiles = { desktop.enable = true; diff --git a/home/modules/editors/default.nix b/home/modules/editors/default.nix index fca5958..e87e46d 100644 --- a/home/modules/editors/default.nix +++ b/home/modules/editors/default.nix @@ -2,5 +2,6 @@ { imports = [ + ./emacs.nix ]; } diff --git a/home/modules/editors/emacs.nix b/home/modules/editors/emacs.nix new file mode 100644 index 0000000..e410df2 --- /dev/null +++ b/home/modules/editors/emacs.nix @@ -0,0 +1,14 @@ +{ config, inputs, lib, options, pkgs, ... }: + +with lib; +let + cfg = config.samfelag.modules.editors.emacs; +in { + options.samfelag.modules.editors.emacs = { + enable = mkEnableOption "emacs"; + }; + + config = mkIf cfg.enable { + # xdg.configFile."doom".src = ../../../config/doom; + }; +} diff --git a/system/hosts/reykjavik/default.nix b/system/hosts/reykjavik/default.nix index c34a7cb..f92f253 100644 --- a/system/hosts/reykjavik/default.nix +++ b/system/hosts/reykjavik/default.nix @@ -17,6 +17,7 @@ samfelag.modules = { user.name = "marc"; bluetooth.enable = true; + editors.emacs.enable = true; }; diff --git a/system/modules/editors/default.nix b/system/modules/editors/default.nix index fca5958..e87e46d 100644 --- a/system/modules/editors/default.nix +++ b/system/modules/editors/default.nix @@ -2,5 +2,6 @@ { imports = [ + ./emacs.nix ]; } diff --git a/system/modules/editors/emacs.nix b/system/modules/editors/emacs.nix new file mode 100644 index 0000000..77df2dd --- /dev/null +++ b/system/modules/editors/emacs.nix @@ -0,0 +1,119 @@ +{ config, inputs, lib, options, pkgs, ... }: + +with lib; +let + cfg = config.samfelag.modules.editors.emacs; +in { + options.samfelag.modules.editors.emacs = { + enable = mkEnableOption "emacs"; + }; + + config = mkIf cfg.enable { + nixpkgs.overlays = [ inputs.emacs-overlay.overlay ]; + + # home.file.doom-emacs = { + # source = ./doom-emacs; + # target = ".config/doom"; + # recursive = true; + # # onChange = "doom upgrade"; + # }; + + # home.programs.emacs = { + # enable = true; + # # package = pkgs.emacsPgtkGcc; + # extraPackages = epkgs: [ epkgs.vterm ]; + # }; + + # home.services.emacs = { + # enable = true; + # client.enable = true; + # socketActivation.enable = true; + # }; + + environment.systemPackages = with pkgs; [ + ## Emacs itself + binutils + emacs + # emacsPgtkGcc + + ## Doom dependencies + git + (ripgrep.override { withPCRE2 = true; }) + gnutls + + ## Opt deps + fd + imagemagick + pinentry_emacs + zstd + + # ## Modules deps + # # :lang cc + # ccls + # cmake + # gcc + # glslang + # # :lang haskell + # stack + # haskellPackages.ghcide + # haskellPackages.hoogle + # # :lang latex && :lang org (latex preview) + # (texlive.combine { inherit (texlive) scheme-full; }) + # # biber + # # :lang nix + # nixfmt + # # :lang python + # black + # python3 + # python3Packages.isort + # # python3Packages.python-language-server + # python3Packages.pytest + # python3Packages.setuptools + # nodePackages.pyright + # # :tools lookup & :lang org +roam + # sqlite + # # :tools direnv + # direnv + # # :tools vterm + # gcc + # gnumake + # libtool + + # Fonts + emacs-all-the-icons-fonts + # fira-code + # fira-code-symbols + + graphviz + ]; + + fonts.fonts = [ pkgs.emacs-all-the-icons-fonts ]; + + # env.PATH = [ "$XDG_CONFIG_HOME/emacs/bin" ]; + + environment.sessionVariables = rec { + XDG_CACHE_HOME = "$HOME/.cache"; + XDG_CONFIG_HOME = "$HOME/.config"; + XDG_BIN_HOME = "$HOME/.local/bin"; + XDG_DATA_HOME = "$HOME/.local/share"; + + PATH = [ + "$HOME/.config/emacs/bin" + ]; + }; + + home-manager.users.marc.xdg.configFile."doom".source = ../../../config/doom; + + system.userActivationScripts = { + installDoomEmacs = '' + EMACS_FOLDER="$HOME/.config/emacs" + echo $XDG_CONFIG_HOME + echo $EMACS_FOLDER + if [ ! -d "$EMACS_FOLDER" ]; then + ${pkgs.git}/bin/git clone --depth=1 --single-branch "https://github.com/doomemacs/doomemacs" "$EMACS_FOLDER" + fi + ''; + }; + + }; +} diff --git a/system/profiles/common.nix b/system/profiles/common.nix index 57b5a9b..143c145 100644 --- a/system/profiles/common.nix +++ b/system/profiles/common.nix @@ -12,7 +12,7 @@ gc = { automatic = true; dates = "weekly"; - options = "--delete-older-than 30d"; + options = "--delete-older-than 14d"; }; };