I use direnv
to automatically get into flake shell as soon as I entre the directory which contain the flake.nix
, the content of .envrc
file is:
use flake
Most of the time I just need to use the package available in my shell for my dev work and the snipet that I use is:
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = import nixpkgs {
inherit system;
};
buildInputs = with pkgs;
[
# package1
# package2
];
in
with pkgs;
{
devShells.default = mkShell {
inherit buildInputs;
};
}
);
}
Sometime I write custom scrips that I need access to, I can create a nixified version using the writeShellApplication
which is one of the trivial builders. Bottom is just a simple shell script to get the authentication code simlar to google-authenticator
:
{ config, pkgs, ... }:
with pkgs;
writeShellApplication {
name = "totp";
runtimeInputs = with pkgs; [ cloak ];
text = ''
cloak view some_app | tr -d '\n' | pbcopy
'';
}
and for new projects I use nix flake templates from nix flake show templates
using nix flake init -t 'templates#go-hello'
I will keep adding to this post if I find someting that I use often.