Can't rebuild Nixos due to Emacs org ELPA package unavailable upstream

Hi,

This morning I tried to nix flake update and nixos-rebuild switch --flake -v and had the following error:

error: builder for '/nix/store/mn0a6djjnz10459crd4b8kxmwjq2haap-org-9.7.27.tar.drv' failed with exit code 1;
       last 25 log lines:
       > curl: (22) The requested URL returned error: 404
       > Warning: Problem (retrying all errors). Will retry in 2 seconds. 2 retries
       > Warning: left.
       >   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
       > curl: (22) The requested URL returned error: 404
       > Warning: Problem (retrying all errors). Will retry in 4 seconds. 1 retry left.
       >   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
       > curl: (22) The requested URL returned error: 404
       >
       > trying https://elpa.gnu.org/packages/org-9.7.27.tar.lz
       >   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
       >                                  Dload  Upload   Total   Spent    Left  Speed
       >   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
       > curl: (22) The requested URL returned error: 404
       > Warning: Problem (retrying all errors). Will retry in 1 second. 3 retries left.
       >   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
       > curl: (22) The requested URL returned error: 404
       > Warning: Problem (retrying all errors). Will retry in 2 seconds. 2 retries
       > Warning: left.
       >   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
       > curl: (22) The requested URL returned error: 404
       > Warning: Problem (retrying all errors). Will retry in 4 seconds. 1 retry left.
       >   0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
       > curl: (22) The requested URL returned error: 404
       > error: cannot download org-9.7.27.tar from any mirror
       For full logs, run:
         nix log /nix/store/mn0a6djjnz10459crd4b8kxmwjq2haap-org-9.7.27.tar.drv
error: 1 dependencies of derivation '/nix/store/hb1a0sfgzxw5v4q41rqah9n5d27g25ss-emacs-org-9.7.27.drv' failed to build
error: 1 dependencies of derivation '/nix/store/1nl5y7amgwagml619rjq8vx8rq2dcrh1-emacs-org-journal-20250306.1429.drv' failed to build
error: 1 dependencies of derivation '/nix/store/bnrxs5ihmrryrl98600babkikfjp8v0n-emacs-org-noter-20240918.1703.drv' failed to build
error: 1 dependencies of derivation '/nix/store/9ccrh6jmh4iwpccw6q7xk4wwjhnsjz13-emacs-org-roam-20250324.2140.drv' failed to build
error: 1 dependencies of derivation '/nix/store/k9xpb31y9mqfkncyy9jpqy3b9q6wpcg7-emacs-gtk3-with-packages-30.2.drv' failed to build
error: 1 dependencies of derivation '/nix/store/xsdmhb733kgnimwdzdybv9z1ydacrjwy-home-manager-path.drv' failed to build
error: 1 dependencies of derivation '/nix/store/2ly3kjy7snxj8jsv958vlhb4zhif81z0-home-manager-generation.drv' failed to build
error: 1 dependencies of derivation '/nix/store/7ri32jwp5rhx2p2c0szh0if5b9230mn1-user-environment.drv' failed to build
copying path '/nix/store/nwwzxl33x930c6zkxbnrkjmwqmlfwzn7-tinysparql-3.9.2' from 'https://cache.nixos.org'...
error: 1 dependencies of derivation '/nix/store/a6f9vgy0si7gxvb8rnv3zg5bajwqq189-etc.drv' failed to build
error: 1 dependencies of derivation '/nix/store/kxmc70ks66qlsdg9am8bpc6i1q9zb4wk-nixos-system-fixable-25.05.20251124.1c8ba8d.drv' failed to build

The given URL return a 404 indeed: https://elpa.gnu.org/packages/org-9.7.27.tar.lz

The org package is included in Emacs (I’m running Emacs 30.2).

Should this be addressed here at Nixos level, or upstream at Emacs level?

Thanks!

Org is a built-in, and nixpkgs’ emacs is usually very recent, so grabbing org from the elpa package is kinda pointless. I’d suggest changing your emacs configuration not to do that.

It seems weird to me that nix tries to download it from upstream, in either case; that should be cached. This particular version appears to have been yanked, but that shouldn’t necessarily lead to failure.

Can you share your config including at least what you have for emacs and flake.nix? There’s something fishy here.

NixOS 25.11 will be released like next week in either case, so I’d personally just wait for the problem to solve itself, but I’d still like to point out whatever arguable mistakes you’re likely making.

That’s the thing, I’m not intentionnaly getting Org in any other way than by using the built-in package. I most probably call elpa somewhere where it escaped my vigilance but can’t figure out where :slight_smile:

Here’s home.nix:

{ config, pkgs, lib, inputs, ... }:

let

  tex = (pkgs.texliveBasic.withPackages (
    ps: with ps; [
      dvisvgm dvipng # for preview and export as html
      wrapfig amsmath ulem hyperref capt-of beamer
      fontspec
      #(setq org-latex-compiler "lualatex")
      #(setq org-preview-latex-default-process 'dvisvgm)
  ]));

in

{ home.username = "jeremy";
  home.homeDirectory = "/home/jeremy";
  home.stateVersion = "25.05";

  imports = [
    ./programs/vscodium.nix
    ./programs/git.nix
    ./programs/kate.nix
    ./programs/konsole.nix
    ./programs/nvim.nix
    ./programs/plasma.nix
    ./programs/zsh.nix
    ./programs/ssh.nix
    ./programs/emacs/emacs.nix
    ./programs/zed.nix
    ./services/syncthing.nix
    ];

  home.packages = with pkgs; [
 # very long list of packages here, including tex
  ];

  # Let home Manager install and manage itself.
  programs.home-manager.enable = true;

}

programs/emacs/emacs.nix:

{ config, pkgs, lib, ... }:

{ programs.emacs = {
		enable = true;
		package = pkgs.emacs-gtk;
		extraConfig = builtins.readFile ./init.el;
		extraPackages = epkgs: [
			epkgs.dash
			epkgs.dashboard
			epkgs.discover
			epkgs.doom-themes
			epkgs.emacsql
			epkgs.f
			epkgs.forge
			epkgs.highlight-indent-guides
			epkgs.magit
			epkgs.magit-section
			epkgs.markdown-mode
			epkgs.mastodon
			epkgs.neotree
			epkgs.nerd-icons
			epkgs.nix-mode
			epkgs.org-journal
			epkgs.org-roam
			epkgs.org-roam-ui
			epkgs.page-break-lines
			epkgs.projectile
			epkgs.s
			epkgs.yaml
			epkgs.zotxt
		];
	};
}

flake.nix:

{description = "Config NixOS";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-25.05";
    home-manager = {
      url = "github:nix-community/home-manager/release-25.05";
      inputs.nixpkgs.follows = "nixpkgs";
    };
    plasma-manager = {
      url = "github:nix-community/plasma-manager";
      inputs.nixpkgs.follows = "nixpkgs";
      inputs.home-manager.follows = "home-manager";
    };
    audio = {
      url = "github:polygon/audio.nix";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs =
    inputs@{
        nixpkgs,
        home-manager,
        plasma-manager,
        audio,
        ...
      }:
      { nixosConfigurations = {
          fixable = nixpkgs.lib.nixosSystem {
            system = "x86_64-linux";
            modules = [
              ./configuration.nix
              {
                nixpkgs.overlays = [ audio.overlays.default ];
              }
              home-manager.nixosModules.home-manager
              {
                home-manager = {
                  users.jeremy = import ./home.nix;
                  useGlobalPkgs = true;
                  useUserPackages = true;
                  sharedModules = [
                    plasma-manager.homeManagerModules.plasma-manager
                  ];
                  backupFileExtension = "bak2";
                };
              }
            ];
            specialArgs = { inherit inputs; };
          };
        };
      };
}

flake.lock:

{
  "nodes": {
    "audio": {
      "inputs": {
        "nix-buildproxy": "nix-buildproxy",
        "nixpkgs": [
          "nixpkgs"
        ]
      },
      "locked": {
        "lastModified": 1763326960,
        "narHash": "sha256-NjvypWkSUWeDTOStRRFoOG14q7JHsmX1feCWO1aSvOQ=",
        "owner": "polygon",
        "repo": "audio.nix",
        "rev": "24bc1becad1105dad1a543f528919339144f3bc5",
        "type": "github"
      },
      "original": {
        "owner": "polygon",
        "repo": "audio.nix",
        "type": "github"
      }
    },
    "home-manager": {
      "inputs": {
        "nixpkgs": [
          "nixpkgs"
        ]
      },
      "locked": {
        "lastModified": 1763992789,
        "narHash": "sha256-WHkdBlw6oyxXIra/vQPYLtqY+3G8dUVZM8bEXk0t8x4=",
        "owner": "nix-community",
        "repo": "home-manager",
        "rev": "44831a7eaba4360fb81f2acc5ea6de5fde90aaa3",
        "type": "github"
      },
      "original": {
        "owner": "nix-community",
        "ref": "release-25.05",
        "repo": "home-manager",
        "type": "github"
      }
    },
    "nix-buildproxy": {
      "inputs": {
        "nixpkgs": [
          "audio",
          "nixpkgs"
        ]
      },
      "locked": {
        "lastModified": 1708455753,
        "narHash": "sha256-qP79WfPiTl92KrZkmvacba9Xas4WwSFln5DjkP2Q/Lg=",
        "owner": "polygon",
        "repo": "nix-buildproxy",
        "rev": "77d486cb4b0458cb4c4a296c3140f7a6c36ab3e6",
        "type": "github"
      },
      "original": {
        "owner": "polygon",
        "ref": "v0.1.0",
        "repo": "nix-buildproxy",
        "type": "github"
      }
    },
    "nixpkgs": {
      "locked": {
        "lastModified": 1763948260,
        "narHash": "sha256-dY9qLD0H0zOUgU3vWacPY6Qc421BeQAfm8kBuBtPVE0=",
        "owner": "nixos",
        "repo": "nixpkgs",
        "rev": "1c8ba8d3f7634acac4a2094eef7c32ad9106532c",
        "type": "github"
      },
      "original": {
        "owner": "nixos",
        "ref": "nixos-25.05",
        "repo": "nixpkgs",
        "type": "github"
      }
    },
    "plasma-manager": {
      "inputs": {
        "home-manager": [
          "home-manager"
        ],
        "nixpkgs": [
          "nixpkgs"
        ]
      },
      "locked": {
        "lastModified": 1763909441,
        "narHash": "sha256-56LwV51TX/FhgX+5LCG6akQ5KrOWuKgcJa+eUsRMxsc=",
        "owner": "nix-community",
        "repo": "plasma-manager",
        "rev": "b24ed4b272256dfc1cc2291f89a9821d5f9e14b4",
        "type": "github"
      },
      "original": {
        "owner": "nix-community",
        "repo": "plasma-manager",
        "type": "github"
      }
    },
    "root": {
      "inputs": {
        "audio": "audio",
        "home-manager": "home-manager",
        "nixpkgs": "nixpkgs",
        "plasma-manager": "plasma-manager"
      }
    }
  },
  "root": "root",
  "version": 7
}

and programs/emacs.init.el, because why not:

;;; init.el --- Config Emacs -*- lexical-binding: t; -*-

;; -----------------------
;; Environnement
;; -----------------------
(setq tool-bar-position 'left) ;; barre d'outils Ă  gauche
(tool-bar-mode 1) ;; réactive la barre d'outils pour être sûr
(setq inhibit-startup-screen t) ;; pas d’écran d’accueil
(savehist-mode 1) ;; historise minibuffer
(recentf-mode 1) ;; fichiers récents
(electric-pair-mode 1) ;; autocomplète (), {}, "", etc.
(global-set-key (kbd "C-c l") #'org-store-link)
(global-set-key (kbd "C-c a") #'org-agenda)
(global-set-key (kbd "C-c c") #'org-capture)
;; (menu-bar-mode -1) ;; masque la barre de menus
;; (tool-bar-mode -1) ;; masque la barre d'outils
;; (scroll-bar-mode -1) ;; masque la barre de défilement
(global-auto-revert-mode 1) ;; active l'auto-revert pour garder les bufffers Ă  jour (cf. syncthing)
;; (auto-save-visited-mode 1) ;; auto-sauvegarde des fichiers visités toutes les 5 secondes

;; Dashboard au démarrage
(use-package dashboard
  :config
  (dashboard-setup-startup-hook)
  (setq dashboard-projects-backend 'projectile)
  (setq dashboard-banner-logo-title "Emacs et soir, bonsoir")
  (setq dashboard-startup-banner 'logo)
  (setq dashboard-items '((recents   . 5)
                        (bookmarks . 5)
                        (projects  . 5)
                        (agenda    . 5)
                        (registers . 5)))
  (setq dashboard-item-names '(("Recent Files:"               . "Fichiers récents :")
                             ("Agenda for today:"           . "Aujourd'hui :")
                             ("Agenda for the coming week:" . "Agenda :")
			     ("Bookmarks:"                  . "Marque-pages :")))
  (setq dashboard-display-icons-p t)     ; display icons on both GUI and terminal
  (setq dashboard-icon-type 'nerd-icons) ; use `nerd-icons' package
  (add-to-list 'dashboard-items '(agenda) t)
  (setq dashboard-week-agenda t)
  (setq dashboard-filter-agenda-entry 'dashboard-no-filter-agenda)
  )

(setq org-latex-compiler "lualatex")
(setq org-preview-latex-default-process 'dvisvgm)

;; Discover
(use-package discover)
(global-discover-mode 1)

;; Guides d'indentation
(use-package highlight-indent-guides
  :hook (prog-mode . highlight-indent-guides-mode)
  :config
  (setq highlight-indent-guides-method 'column)) ;; character ou column

(show-paren-mode 1) ;; surligne les wparenthèses appariées

;; --------
;; Org-mode
;; --------

(use-package org
  :bind (("C-c l" . org-store-link)
         ("C-c a" . org-agenda))
  :custom
  (org-log-done t) ;; horodatage auto des DONE
  (org-src-fontify-natively t) ;; color synt dans les bloc de code
  (org-confirm-babel-evaluate nil) ;; pas de confirmation avant eval des blocs de code Babel
;;   (org-hide-emphasis-markers t) ;; cacher le markup pour gras & italiques
  (org-startup-indented t) ;; indentation intelligente plus lisible
  :init
;;  (setq org-agenda-files '("~/org", "~/org/junarka/"))
  (setq org-agenda-files (directory-files-recursively "~/org" "\\.org$"))

  (setq org-agenda-files
      (seq-filter
       (lambda (file) (not (string-match-p "doc/" file)))
       (directory-files-recursively "~/org" "\\.org$")))
  
  (setq org-babel-load-languages
        '((emacs-lisp . t)
          (python . t)
          (shell . t)
          (js . t)))
  :config
  ;; autorise l'exécution des blocs de code sans confirmation par langage
  (org-babel-do-load-languages
   'org-babel-load-languages
   org-babel-load-languages))

;; --------
;; Org-roam
;; --------

(use-package org-roam
  :after org
  :custom
  (org-roam-directory (file-truename "~/org-roam"))
  (org-roam-completion-everywhere t)
  (org-roam-dailies-directory "daily/")
  (org-roam-dailies-date-format "%Y_%m_%d")
  :bind (("C-c n l" . org-roam-buffer-toggle)
         ("C-c n f" . org-roam-node-find)
         ("C-c n i" . org-roam-node-insert)
         ("C-c n t" . org-roam-dailies-goto-today)
         ("C-c n y" . org-roam-dailies-goto-yesterday)
         ("C-c n T" . org-roam-dailies-goto-tomorrow))
;;          :map org-mode-map
;;          ("C-M-i" . completion-at-point)
;;          :map org-roam-dailies-map
;;          ("Y" . org-roam-dailies-capture-yesterday)
;;          ("T" . org-roam-dailies-capture-tomorrow))
  :config
  (require 'org-roam-dailies)
  (org-roam-db-autosync-mode))

;; Raccourcis supplémentaires pour les dailies
;; (with-eval-after-load 'org-roam-dailies
;;   (define-key org-roam-dailies-map (kbd "Y") #'org-roam-dailies-capture-yesterday)
;;   (define-key org-roam-dailies-map (kbd "T") #'org-roam-dailies-capture-tomorrow))

;; Raccourci pour la complétion dans org-mode
(with-eval-after-load 'org
  (define-key org-mode-map (kbd "C-M-i") #'completion-at-point))

;; (use-package org-roam-dailies
;;   :after org-roam
;;   :bind-keymap ("C-c n d" . org-roam-dailies-map))


;; -----
;; Magit
;; -----

(use-package magit
  :defer t  ;; charge Magit seulement quand on l'utilise
  :commands (magit-status magit-blame)
  :bind (("C-x g" . magit-status))  ;; raccourci classique
  :custom
  ;; éviter les confirmations inutiles
  (magit-display-buffer-function #'magit-display-buffer-same-window-except-diff-v1)
  ;; plus de détails dans les logs
  (magit-log-margin '(t "%Y-%m-%d %H:%M " magit-log-margin-width t 18))
  ;; confirmation automatique pour certaines actions
  (magit-save-repository-buffers 'dontask)
  :config
  ;; active forge pour gérer les issues pour Github/Gitlab
  (use-package forge
    :after magit))

;; -------
;; neotree
;; -------

(add-to-list 'load-path "~/")
(require 'neotree)
(global-set-key [f8] 'neotree-toggle)
(setq neo-theme (if (display-graphic-p) 'ascii))

;; --------
;; nix-mode
;; --------

(use-package nix-mode
  :mode "\\.nix\\'")

;; -----
;; THEME
;; -----

(use-package doom-themes
  :custom
  ;; Global settings (defaults)
  (doom-themes-enable-bold t)   ; if nil, bold is universally disabled
  (doom-themes-enable-italic t) ; if nil, italics is universally disabled
  ;; for treemacs users
  (doom-themes-treemacs-theme "doom-atom") ; use "doom-colors" for less minimal icon theme
  :config
  (load-theme 'doom-vibrant t)

  ;; Enable flashing mode-line on errors
  (doom-themes-visual-bell-config)
  ;; Enable custom neotree theme (nerd-icons must be installed!)
  (doom-themes-neotree-config)
  ;; or for treemacs users
  (doom-themes-treemacs-config)
  ;; Corrects (and improves) org-mode's native fontification.
  (doom-themes-org-config))

(add-hook 'prog-mode-hook 'display-line-numbers-mode)

(add-hook 'text-mode-hook 'visual-line-mode)

;; Mastodon
;; --------

(use-package mastodon
  :config
  (mastodon-discover)
  (setq mastodon-instance-url "https://mapstodon.space"
        mastodon-active-user "jeremy"))

Right, it must be a recursive dependency of one (or more) of these:

Your build trace actually tells us it’s org-roam. It’s possible to override that package so it doesn’t depend on org, at which point it should fall back to the built-in version, but I’d have to look at how elpaPackage works again to give you more than pseudocode.

It’d look something like this:

(epkgs.org-roam.overrideAttrs (drv: {
  buildInputs = lib.filter (pkg: pkg.pname == "emacs-org") drv.buildInputs;
})

… but I think the buildInputs might be wrong. Or not. Depends on how elpaPackage propagates to mkDerivation.

Alternatively you can just wait a week, of course, or go update the version of org in nixpkgs-25.05 upstream; there might even be an issue about it already. Or maybe try the 25.11 beta branch :wink:

You shouldn’t use that if you use the NixOS module FYI.

3 Likes

Thanks for the suggestions! I’ll look into it.

Regarding:

  # Let home Manager install and manage itself.
  programs.home-manager.enable = true;

Are you saying that if I use Home Manager through flakes I don’t need it?

I added this line following Home Manager manual’s configuration tips.

No, if you used home-manager standalone you would need it, regardless of whether you use flakes or not.

If you use home-manager with NixOS you don’t need it.

Yeah, the home-manager manual is pretty bad at explaining the different modes of home-manager, and worse yet at clearly signalling which part of the docs relate to which mode. Most of the docs in that section relate to using home-manager standalone.

Basically there’s this matrix of different home-manager use cases:

Command matrix Standalone NixOS module nix-darwin module
Traditional nix home-manager nixos-rebuild darwin-rebuild
Flakes home-manager --flake nixos-rebuild --flake darwin-rebuild

You only need to enable the home-manager command (which is what that option does) if you need to use the home-manager command to deploy your config. In the other cases, the platform’s usual deployment command instead also activates the home-manager activation script.

This incidentally has a bunch of other implications, from which nixpkgs channel/config ends up taking priority to error messages being swallowed. The docs really should do a better job at explaining this, honestly each mode should have its own, completely separate page.

1 Like

Apparently the url for this package has changed upstream. My best guess is that they now keep the .tar only for the latest version upstream. The correct url is now http://elpa.gnu.org/packages/org-9.7.34.tar.lz, as listed in GNU ELPA - org.

You could open a MR to nixpkgs to fix that. Note: master is also affected so it’s a worthy fix to include for the 25.11 release. You can then ask for backport if you plan to stay a bit more on 25.05. The file in question seems to be pkgs/applications/editors/emacs/elisp-packages/elpa-generated.nix.

I don’t think it has something to do with circular dependencies.

Just for the record, as for now, I’ve identified that the issue came from the emacs package itself, when declared with programs.emacs.enable=true.

I really don’t think so; by setting programs.emacs.enable = false;, you’re just also disabling the bit of home-manager code that installs the packages from extraPackages, and thereby no longer evaluating the org packages that in turn need to be rebuilt from (a nonexistent) source.

You could just comment out the org-related packages, instead. But now I wonder how you haven’t noticed your editor disappearing.

Sorry, my message lacked a bit of explanation! Here’s what I did exactly:

  • I removed org-roam-ui from programs/emacs/emacs.nix, commited and rebuild, it still didn’t work
  • I removed org-roam from programs/emacs/emacs.nix, commited and rebuild, it still didn’t work
  • I removed org-journal from programs/emacs/emacs.nix, commited and rebuild, it still didn’t work
  • I commented the import line for programs/emacs/emacs.nix in home.nix, and it properly rebuild.

See ~mapper/nixos-fixable - NixOS config on fixable - sourcehut git log for the most recent commits.

That’s why i assumed the issue was coming from emacs itself, though it could also come from another package from extraPackages than relies on org but I can’t see which one it would be.

If you read your logs they will tell you. E.g. with the ones you’ve shared:

See the names if the store paths end in emacs-<package>-<hash>? Just remove any packages implicated in the logs.