Skip to content

Instantly share code, notes, and snippets.

View infinisil's full-sized avatar

Silvan Mosberger infinisil

  • Tweag
  • Switzerland
View GitHub Profile
@infinisil
infinisil / default.nix
Last active December 31, 2023 17:25
LookingGrimm
{
system ? builtins.currentSystem,
pkgs ?
import (fetchTarball {
url = "https://github.com/NixOS/nixpkgs/tarball/cfc3698c31b1fb9cdcf10f36c9643460264d0ca8";
sha256 = "1xn1k48w678hjkrx434n995i68jwkxrwpncyjzrmfz0i9p2y7igh";
}) {
config = {};
overlays = [];
inherit system;
@infinisil
infinisil / builtins-local-paths.md
Last active November 20, 2023 23:20
Tutorial on outdated practices regarding using builtins on local paths

Setting up a local experiment

To experiment with source file selection, we'll set up a local project.

To start out, create a new directory, enter it, and set up niv to manage the Nixpkgs dependency:

$ mkdir select
$ cd select
$ nix-shell -p niv --run "niv init --nixpkgs nixos/nixpkgs --nixpkgs-branch nixos-unstable"
@infinisil
infinisil / nix-instantiate-pure
Created November 10, 2023 07:03
Hacky nix-instantiate with convenient pure evaluation mode
#!/usr/bin/env bash
# This is emulating flake's pure evaluation mode
purePathExpr() {
local arg=$1
if [[ -f "$arg" ]]; then
root=$(dirname "$arg")
else
root=$arg
fi
(import <nixpkgs/lib>).evalModules {
modules = [
./generic.nix
./specific1.nix
./specific2.nix
];
}
{ pkgs, lib, config, ... }: with lib.types;
let
postgresqlInstanceType = submodule {
options.connectionString = lib.mkOption {
type = str;
};
};
(import <nixpkgs/lib>).evalModules {
modules = [
({ lib, config, ... }: {
options.foo = lib.mkOption {
type = lib.types.int;
};
options.bar = lib.mkOption {
default = { };

let with

Originally described in NixOS/rfcs#110 (comment)

{ pkgs, hello }:
let
  with pkgs;
  myHello = hello.override { ... };
in [
- [f3031298b22e](https://github.com/NixOS/nixpkgs/commit/f3031298b22ed05a0b46728fa4f053a990a562f1) [@marsam](https://github.com/marsam) - chipsec: disable on non-Linux
- [2cdc05763f4f](https://github.com/NixOS/nixpkgs/commit/2cdc05763f4f857d04ead6c53fe8be23ec441903) [@marsam](https://github.com/marsam) - chipsec: disable on non-Linux
- [7bfde4b33400](https://github.com/NixOS/nixpkgs/commit/7bfde4b33400c1a9b5655a5b13960011a0d6740c) [@zimbatm](https://github.com/zimbatm) - Revert "st: enable build on darwin (#98668)"
- [020ff6989a9e](https://github.com/NixOS/nixpkgs/commit/020ff6989a9ee98f779dc5f9f74b96c4a8090f72) [@NeQuissimus](https://github.com/NeQuissimus) - 1password: 1.1.1 -> 1.7.0
- [5ab14bf6ad62](https://github.com/NixOS/nixpkgs/commit/5ab14bf6ad62873e39a3593d158b599b86267274) [@NeQuissimus](https://github.com/NeQuissimus) - vivaldi: 3.3.2022.39-1 -> 3.3.2022.47-1
- [5d4cc0e25c15](https://github.com/NixOS/nixpkgs/commit/5d4cc0e25c1589f4248c4534260c86647bc4ae73) [@rickynils](https://github.com/rickynils)
❯ cd $(mktemp -d)
❯ git init
Initialized empty Git repository in /tmp/tmp.ovd5lFO665/.git/
❯ echo 1 > foo
❯ git add foo
❯ git commit -m 'Version 1'
[main (root-commit) af124d9] Version 1
1 file changed, 1 insertion(+)
create mode 100644 foo
❯ git switch -c release