nixos-module.nix

1.3 KB · raw

1# Standalone NixOS module for nina — no flake inputs needed.2# Generated by the installer into ~/nina.nix. Also importable directly.3#4# Usage (in configuration.nix):5#   imports = [6#     "${builtins.fetchTarball "https://kepr.uk/nina/archive/HEAD.tar.gz"}/nixos-module.nix"7#   ];8#   programs.nina.enable = true;9#10# For flake-based configs use the flake input instead — see flake.nix.11{ config, pkgs, lib, ... }:12let13  nina-pkg = pkgs.stdenv.mkDerivation {14    pname = "nina";15    version = builtins.replaceStrings [ "\n" "\r" " " "\t" ] [ "" "" "" "" ]16      (builtins.readFile ./VERSION);17    src = ./.;18    nativeBuildInputs = [ pkgs.zig_0_16 ];19    dontConfigure = true;20    buildPhase = ''21      export ZIG_GLOBAL_CACHE_DIR="$TMPDIR/zig-cache"22      zig build -Doptimize=ReleaseSafe23    '';24    installPhase = "install -Dm755 zig-out/bin/nina $out/bin/nina";25    meta = {26      description = "The nix helper — manage your NixOS system from the command line";27      mainProgram = "nina";28    };29  };30  cfg = config.programs.nina;31in {32  options.programs.nina = {33    enable = lib.mkEnableOption "nina, the NixOS helper";34    package = lib.mkOption {35      type = lib.types.package;36      default = nina-pkg;37      description = "The nina package to install.";38    };39  };40  config = lib.mkIf cfg.enable {41    environment.systemPackages = [ cfg.package ];42  };43}