Nix flake library for my repositories
  • Nix 93.5%
  • Just 6.2%
  • Rust 0.3%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Clank ac5597ae8b
All checks were successful
ci/woodpecker/push/verify-nix Pipeline was successful
ci/woodpecker/cron/flake-check Pipeline was successful
chore(deps): update dependency gpu-cli/openapi-to-rust to v0.22.0 (#19)
2026-10-07 06:05:49 +00:00
.woodpecker ci: Use nix-unit plugin for unit tests 2026-08-30 19:37:14 +00:00
lib fix: eachSupportedSystem not outputting correctly 2026-08-08 14:45:00 +02:00
pkgs feat: Add dolt package at 2.2.0 (#17) 2026-10-03 18:58:42 +00:00
test ci(verify-nix): Init verify pipeline (#9) 2026-08-30 14:55:21 +00:00
.gitignore chore: Add target to gitignore 2026-07-27 18:04:19 +02:00
AGENTS.md feat: Add dolt package at 2.2.0 (#17) 2026-10-03 18:58:42 +00:00
CODEOWNERS Migration: codeowners (#4) 2026-07-29 18:15:20 +00:00
flake.lock chore(deps): update dependency gpu-cli/openapi-to-rust to v0.22.0 (#19) 2026-10-07 06:05:49 +00:00
flake.nix chore(deps): update dependency gpu-cli/openapi-to-rust to v0.22.0 (#19) 2026-10-07 06:05:49 +00:00
justfile ci(verify-nix): Init verify pipeline (#9) 2026-08-30 14:55:21 +00:00
LICENSE Initial commit 2026-07-25 12:28:26 +00:00
README.md feat: Add dolt package at 2.2.0 (#17) 2026-10-03 18:58:42 +00:00
renovate.json chore(renovate): Use flake preset 2026-08-08 13:58:07 +02:00
treefmt.nix Initial commit 2026-07-25 15:46:08 +02:00

my-nix-lib

Reusable Nix library functions, exposed through the flake's lib output.

Modules

All attributes are exposed under the flake's lib output and consumed as my.lib.*.

Packages

The flake provides Dolt for x86_64-linux and aarch64-linux as packages.<system>.dolt. For example, use it to override the Dolt dependency in the nixpkgs Beads package:

beads = pkgs.beads.override {
  dolt = my-nix-lib.packages.${system}.dolt;
};

my.lib.domain

Homelab domain configuration — forge URL, auth, container registry, cargo registry.

my.lib.domain.registries.crate
# => { indexUrl = "https://code.martials.no/..."; dl = "..."; registryPrefix = "sparse+"; }

my.lib.defaults

Package defaults, currently just the licence:

my.lib.defaults.licence
# => lib.licenses.mit

my.lib.system

Systems supported by the flake:

my.lib.system.supportedSystems

Use eachSupportedSystem to create flake outputs for every supported system. The function transposes the result, so consumers do not need a separate transpose step:

my.lib.system.eachSupportedSystem (system: {
  packages.default = ...;
  devShells.default = ...;
  checks.example = ...;
})
# => { packages.${system} = ...; devShells.${system} = ...; checks.${system} = ...; }

my.lib.<system>.rust

Rust build helpers using crane + fenix.

Function Returns Description
mkCraneLib { } crane lib Crane library with the configured toolchain
mkDevShell { } dev shell Shell ready for Rust development
mkRustPlatform { } rust platform craneLib.appendCrateRegistries with configured registries

mkCraneLib

Returns a crane library with the configured toolchain.

Arg Default Description
channel "stable" Rust toolchain channel
tooltip "minimalToolchain" fenix toolchain attribute

mkDevShell

Returns a dev shell with the configured toolchain.

Containing the packages rust-analyzer, cargo, rustfmt, clippy. shellHook exports LD_LIBRARY_PATH to the shell.

Arg Default Description
channel "stable" Rust toolchain channel
tooltip "minimalToolchain" fenix toolchain attribute
packages [] Extra packages to include in the shell
shellHook "" Shell hook script

mkRustPlatform

Arg Default Description
channel "stable" Rust toolchain channel
tooltip "minimalToolchain" fenix toolchain attribute
registries [] Extra crate registries

Automatically prepends my.lib.domain.registries.crate (with {crate}/{version}/download suffix appended) to the registries list, so the private crate registry is configured by default.

Minimal usage:

let
  craneLib = my.lib.${system}.rust.mkCraneLib { };
  rustPlatform = my.lib.${system}.rust.mkRustPlatform { };
in {
  packages.default = rustPlatform.buildPackage {
    src = lib.cleanSource ./.;
    nativeBuildInputs = with pkgs; [ pkg-config ];
    buildInputs = with pkgs; [ openssl ];
  };
  devShells.default = my.lib.${system}.rust.mkDevShell {
    packages = with pkgs; [ pkg-config openssl ];
  };
}

With extra registries:

my.lib.${system}.rust.mkRustPlatform {
  registries = [
    { indexUrl = "https://..." ; dl = "https://..." ; registryPrefix = "sparse+"; }
  ];
}

Usage

Add my-nix-lib as a flake input and access its library output directly:

# flake.nix
{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-26.05";
    my-nix-lib.url = "github:martinals/my-nix-lib";
    fenix.url = "github:nix-community/fenix";
    crane.url = "github:ipetkov/crane";
  };

  outputs = { self, my-nix-lib, ... }:
    let
      systems = my-nix-lib.lib.system.supportedSystems;
    in
    builtins.genAttrs systems (system:
      let
        my = my-nix-lib;
      in {
        # my.lib.domain / my.lib.defaults / my.lib.${system}.rust
      }
    );
}