nvim/snippets/nix.snippets
2025-11-05 19:29:55 +01:00

54 lines
1.1 KiB
Text

snippet shell nix-shell
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
buildInputs = with pkgs; [
$1
];
}
snippet optionalAttrs
lib.attrsets.optionalAttrs $1 $2
snippet deps
let pkgs = import <nixpkgs> {}; in
with pkgs; [ $1 ]
snippet flake
{
description = "Flake for $1";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs =
{
self,
nixpkgs,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = nixpkgs.legacyPackages.\${system};
in
rec {
packages = rec {
$1 = pkgs.stdenv.mkDerivation {
name = "$1";
buildInputs = with pkgs; [
$2
];
};
default = $1;
};
devShells.default = pkgs.mkShell {
inputsFrom = [ packages.default ];
packages = with pkgs; [
$3
];
};
}
);
}