nix-community/nix-doom-emacs

"Permission denied" error when trying to install doom-emacs

victorpigmeo opened this issue · 3 comments

I started with nixos a few days ago so it is possible that this is some mistake made by me.
When I try to install doom-emacs I got this error:

[nix-doom-emacs] Advising doom installer to gather packages to install...
Loading /nix/store/jkxpk8rfyb1fiyrv3kyhsjqdqav4ph5v-doom-src/bin/doom...
> Executing 'doom install' with Emacs 27.2 at 2022-01-26 00:45:39
  Installing Doom Emacs!
  
  > Creating /nix/store/0yj96lx7qhy1xhyq7pn09z25cjbx65zd-doom.d/
    ✓ Created /nix/store/0yj96lx7qhy1xhyq7pn09z25cjbx65zd-doom.d/
  - Creating /nix/store/0yj96lx7qhy1xhyq7pn09z25cjbx65zd-doom.d/init.el
  x There was an unexpected error
    Message: File error
    Error: (file-error "Opening output file" "Permission denied" "/nix/store/0yj96lx7qhy1xhyq7pn09z25cjbx65zd-doom.d/init.el")
    Backtrace:
      (write-region nil nil "/nix/store/0yj96lx7qhy1xhyq7pn09z25cjbx65zd-doom.d/...
      (save-current-buffer (set-buffer temp-buffer) (write-region nil nil temp-f...
      (prog1 (save-current-buffer (set-buffer temp-buffer) (insert-file-contents...
      (unwind-protect (prog1 (save-current-buffer (set-buffer temp-buffer) (inse...
      (let ((temp-file (doom-path doom-private-dir filename)) (temp-buffer (gene...
      (if (let ((p (let ((file filename)) (and (stringp file) (let ((default-dir...
      (let* ((template file) (filename (if template (car-safe (prog1 template (s...
      ((closure ((nofonts-p) (noinstall-p) (noenv-p) (noconfig-p) (--alist--) (p...
      (mapc (closure ((nofonts-p) (noinstall-p) (noenv-p) (noconfig-p) (--alist-...
      (if noconfig-p (doom--print (doom--format (format (doom--output-class 'war...
  ! Extended backtrace logged to /build/tmp.UX26Pmuoc8/local/doom.error.log
[nix-doom-emacs] Inhibiting (kill-emacs)

Error in kill-emacs-hook (straight--transaction-finalize): (file-missing "Opening output file" "No such file or directory" "/build/tmp.UX26Pmuoc8/local/straight/build-27.2-cache.el")

As of now, my configuration looks like this:

# 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, lib, ... }:

let
  home-manager = builtins.fetchTarball "https://github.com/nix-community/home-manager/archive/master.tar.gz";
  # doom-emacs = pkgs.callPackage (builtins.fetchTarball {
  #   url = https://github.com/nix-community/nix-doom-emacs/archive/master.tar.gz;
  #   }) {
  #     doomPrivateDir = /home/victor/doom.d;
  #   };
in
{

  imports =
    [ # Include the results of the hardware scan.
      ./hardware-configuration.nix
      (import "${home-manager}/nixos")
    ];

  # services.emacs.package = pkgs.emacsPgtkGcc;
  # nixpkgs.overlays = [
  #   (import (builtins.fetchGit {
  #     url = "https://github.com/nix-community/emacs-overlay.git";
  #     ref = "master";
  #     rev = "c6b057968bbb9a68541ce3edfdf4aa01c32de369";
  #   }))
  # ];

  nixpkgs.config.allowUnfree = true;
  programs.zsh.enable = true;
  users.defaultUserShell = pkgs.zsh;

  home-manager.users.victor = {
    home.packages = with pkgs; [
      vim
      terminator
      spotify
      git
      google-chrome
      vscode
      zsh
      # emacsPgtkGcc
      # doom-emacs
    ];

    home.file.".emacs.d/init.el".text = ''
      (load "default.el")
    '';
...

I take only the part with doom/emacs configuration (commented), if needed I can commit it all on some repo.
The README.md file on this repo it's not so friendly for people who is new to nix, do I have to install emacs with those overlays before installing this package? Or it does it all?

ckiee commented

I started with nixos a few days ago [...]

Welcome! I'm very direct but that means I solve problems (:

When I try to install doom-emacs I got this error:

Looks like your doomPrivateDir (/home/victor/doom.d) is missing the required init.el file, you can use this template doom.d.

The README.md file on this repo it's not so friendly for people who is new to nix

Nix is one big dookie and writing documentation isn't nearly as fun as getting things working... (at least for me)

do I have to install emacs with those overlays before installing this package? Or it does it all?

It should do everything:

  • You don't actually need this:
    home.file.".emacs.d/init.el".text = ''
      (load "default.el")
    '';
  • Or these:
  # services.emacs.package = pkgs.emacsPgtkGcc;
  # nixpkgs.overlays = [
  #   (import (builtins.fetchGit {
  #     url = "https://github.com/nix-community/emacs-overlay.git";
  #     ref = "master";
  #     rev = "c6b057968bbb9a68541ce3edfdf4aa01c32de369";
  #   }))
  # ];
  • Or this:
      # emacsPgtkGcc
  • But you probably do want this in the home-manager block:
services.emacs = {
 enable = true;
 package = doom-emacs;
};

Now, this will run, but won't configure stuff like fonts for you.. You can fix that by importing the home-manager module and doing something like this.


Some other things I noticed:

  • You use a path from /home/victor/doom.d. That doesn't sound very portable, ideally you should be able to copy your NixOS configuration and yote it on another machine and have it build right away.
  • You use fetchTarball and specify stuff like ​h​t​t​p​s​://github.com/blah/blah/archive/master.tar.gz. This is bad because your config might build one day and break the next when those URLs update. Nix lets you avoid this mess which is very nice.

Signed,
A bored Nix user distracting themselves from life with ✨fancy packaging tools✨!

Wow thank you so much for this awesome detailed message :)
I just don't got the fetchTarball part, is it better to use a fixed revision instead of master? That was your point?
Again, thank you, it is working now!

ckiee commented

Wow thank you so much for this awesome detailed message :)

No problem :P

I just don't got the fetchTarball part, is it better to use a fixed revision instead of master? That was your point?

Yeah! I personally use niv but with flakes being popular now you should probably look into them instead.