Skip to content

Instantly share code, notes, and snippets.

@rgoulter
Created April 25, 2024 07:49
Show Gist options
  • Save rgoulter/fc8863d085d98276d8d51b1f301e150a to your computer and use it in GitHub Desktop.
Save rgoulter/fc8863d085d98276d8d51b1f301e150a to your computer and use it in GitHub Desktop.
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1710146030,
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1713805509,
"narHash": "sha256-YgSEan4CcrjivCNO5ZNzhg7/8ViLkZ4CB/GrGBVSudo=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "1e1dc66fe68972a76679644a5577828b6a7e8be4",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}
{
inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
};
outputs = {
self,
flake-utils,
nixpkgs,
}:
flake-utils.lib.eachDefaultSystem
(system:
let pkgs = nixpkgs.legacyPackages.${system}; in
{
packages.hello =
pkgs.callPackage ./hello.nix {
trivialBuild = pkgs.emacs.pkgs.trivialBuild;
};
}
);
}
;;; hello.el --- Description -*- lexical-binding: t; -*-
(defun hello ()
"Say hello."
(interactive)
(message "Hello, world!"))
(provide 'hello)
;;; hello.el ends here
{
trivialBuild,
}:
trivialBuild rec {
pname = "hello";
version = "v1.0.0";
src = ./.;
}
@rgoulter
Copy link
Author

Use this with e.g. a flake.nix like:

{
  inputs = {
    flake-utils.url = "github:numtide/flake-utils";
    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
    hello.url = "git+https://gist.github.com/rgoulter/fc8863d085d98276d8d51b1f301e150a";
  };
  outputs = {
    self,
    flake-utils,
    nixpkgs,
    hello,
  }@inputs:
    flake-utils.lib.eachDefaultSystem
      (system:
        let
          pkgs = nixpkgs.legacyPackages.${system};
          hello = inputs.hello.packages.${system}.hello;
        in
        {
          packages.emacs =
            pkgs.emacs.pkgs.emacsWithPackages (epkgs: [
              hello
            ]);
        }
      );
}

Then running the resulting emacs with emacs -Q, the following Elisp should echo 'hello world':

(require 'hello)
(hello)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment