Skip to content

Instantly share code, notes, and snippets.

@isaac-ped
Created June 27, 2023 18:43
Show Gist options
  • Save isaac-ped/cede659aff702e799dbd79584c49dae7 to your computer and use it in GitHub Desktop.
Save isaac-ped/cede659aff702e799dbd79584c49dae7 to your computer and use it in GitHub Desktop.
Minimal nix setup
#!/usr/bin/env bash
## This is copied directly from `lorri init`
# the shebang is ignored, but nice for editors
if type -P lorri &>/dev/null; then
eval "$(lorri direnv)"
else
echo 'while direnv evaluated .envrc, could not find the command "lorri" [https://github.com/nix-community/lorri]'
use nix
fi

Minimal nix setup

  • Copy in these files
  • nix flake lock
  • direnv allow
  • lorri watch --once
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
flake-utils.url = "github:numtide/flake-utils";
};
# If you add other inputs above, also add them to the arguments
# of the outputs function here:
outputs = {
self,
nixpkgs,
flake-compat,
flake-utils
}:
# Creates an output for each system:
flake-utils.lib.eachDefaultSystem( system:
let
pkgs = import nixpkgs { inherit system; };
shell = pkgs.mkShell {
packages = [
# Add packages here. e.g.:
pkgs.poetry
];
};
in
{
# We're only defining devShell in the system-specific output
devShell = shell;
}
);
}
# A compatibility layer around flake.nix so that lorri still functions
{ system ? builtins.currentSystem }:
(import (
fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/12c64ca55c1014cdc1b16ed5a804aa8576601ff2.tar.gz";
sha256 = "0jm6nzb83wa6ai17ly9fzpqc40wg1viib8klq8lby54agpl213w5"; }
) {
src = ./.;
}).shellNix.default
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment