Add flake.nix

Add a new flake.nix for this repo, having extracted it from
nixos-configs. Add packages.nix copied from nixos-configs, as I
accidentally removed it while filtering to create this repo.
This commit is contained in:
Sam W 2022-06-14 01:53:34 +01:00
parent a30452afbc
commit 500bcd20eb
5 changed files with 239 additions and 8 deletions

106
flake.lock Normal file
View File

@ -0,0 +1,106 @@
{
"nodes": {
"devshell": {
"inputs": {
"flake-utils": [
"flake-utils"
],
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1654858401,
"narHash": "sha256-53bw34DtVJ2bnF6WEwy6Tym+qY0pNEiEwARUlvmTZjs=",
"owner": "numtide",
"repo": "devshell",
"rev": "f55e05c6d3bbe9acc7363bc8fc739518b2f02976",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "devshell",
"type": "github"
}
},
"flake-utils": {
"locked": {
"lastModified": 1653893745,
"narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"home-manager": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1654113405,
"narHash": "sha256-VpK+0QaWG2JRgB00lw77N9TjkE3ec0iMYIX1TzGpxa4=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "ac2287df5a2d6f0a44bbcbd11701dbbf6ec43675",
"type": "github"
},
"original": {
"owner": "nix-community",
"ref": "release-22.05",
"repo": "home-manager",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1654994491,
"narHash": "sha256-HFu3HTFFFcZSKImuiki3q+MLvcc85hRgYvW+sXmH8LE=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "1f8d88087a3753e55a29b5207f7f0997f7c813fa",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-22.05",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-samw": {
"locked": {
"lastModified": 1655065841,
"narHash": "sha256-jFtkxS6k/LzJ/RvDuTk1x/igcRwE7JIoXXv8Lh/QauY=",
"owner": "wlcx",
"repo": "nixpkgs",
"rev": "794deaa7696e76e3f1159f27d2fe8607a4e1f0e6",
"type": "github"
},
"original": {
"owner": "wlcx",
"ref": "pngpaste-0.2.3",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"devshell": "devshell",
"flake-utils": "flake-utils",
"home-manager": "home-manager",
"nixpkgs": "nixpkgs",
"nixpkgs-samw": "nixpkgs-samw"
}
}
},
"root": "root",
"version": 7
}

95
flake.nix Normal file
View File

@ -0,0 +1,95 @@
{
description = "Samw's home environment, as managed by nix/home-manager.";
inputs = {
# Nixpkgs
nixpkgs = {url = "github:nixos/nixpkgs/nixos-22.05";};
nixpkgs-samw = {url = "github:wlcx/nixpkgs/pngpaste-0.2.3";};
# Other modules
home-manager = {
url = "github:nix-community/home-manager/release-22.05";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-utils.url = "github:numtide/flake-utils";
devshell = {
url = "github:numtide/devshell";
inputs.flake-utils.follows = "flake-utils";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = inputs: let
overlays = [
# Add packages from "other" nixpkgs
(final: prev:
with inputs; {
# TODO: get pngpaste PR merged...
pngpaste = nixpkgs-samw.legacyPackages.${prev.system}.pngpaste;
})
# Add our own local packages
(final: prev: rec {
# Make my local packages available as pkgs.mypkgs.<foo>
mypkgs = prev.callPackage ./pkgs {};
# Directly override yubikey-manager
yubikey-manager = mypkgs.yubikey-manager;
})
];
in (rec {
lib = {
mkHome = {
profile,
extraModules ? [],
system,
username ? "samw",
}:
inputs.home-manager.lib.homeManagerConfiguration rec {
inherit username system;
stateVersion = "21.11";
homeDirectory =
if (inputs.nixpkgs.lib.systems.elaborate system).isDarwin
then "/Users/${username}"
else "/home/${username}";
configuration = {...} @ args: ((profile args) // {nixpkgs.overlays = overlays;});
extraSpecialArgs = {inherit system;};
inherit extraModules;
};
};
profiles = import ./home/profiles.nix;
# Standalone home-manager configurations
homeConfigurations = {
boron = lib.mkHome {
system = "aarch64-darwin";
profile = profiles.laptop;
username = "samuel.willcocks";
extraModules = [./home/docker.nix ./home/aws.nix];
};
zinc = lib.mkHome {
profile = profiles.laptop;
system = "aarch64-darwin";
};
};
}
# Per-system things
// (inputs.flake-utils.lib.eachDefaultSystem (system: let
pkgs = import inputs.nixpkgs {
inherit system;
overlays = overlays ++ [inputs.devshell.overlay];
};
platform = pkgs.lib.systems.elaborate system;
in {
# Flake interface to my local packages.
# - `callPackage` puts some junk in mypkgs (`override` and
# `overrideDerivation`) so we filter out anything that isn't a derivation
# - We also filter out any packages that aren't supported on the current
# platform.
packages = with pkgs; (lib.filterAttrs (_: v: (lib.isDerivation v
&& lib.meta.availableOn platform v))
pkgs.mypkgs);
formatter = pkgs.alejandra;
# A devshell with useful utils
devShells.default = pkgs.devshell.mkShell {
packages = [
inputs.home-manager.defaultPackage.${system}
];
};
})));
}

View File

@ -1,8 +1,8 @@
{ pkgs, lib, ... }:
let mypkgs = pkgs.callPackage ../modules/pkgs.nix { };
let packages = pkgs.callPackage ./packages.nix {};
in {
home.packages = mypkgs.all;
home.packages = packages.all;
home.sessionVariables = {
"PATH" = "$HOME/.local/bin:$PATH";
"EDITOR" = "vim";

24
home/packages.nix Normal file
View File

@ -0,0 +1,24 @@
{ pkgs }:
with pkgs; rec {
# The stuff you want installed everywhere. The necessities.
base = [
bat # cat replacement, aliased to cat in home-manager
file
git
htop
lsof
mosh
tmux
unzip
vim
wget
];
# Networking shit
net = [ iperf3 nmap socat tcpdump ];
# development tools
dev = [ jq nixfmt gh glab hexyl ];
all = (base ++ net ++ dev);
}

View File

@ -1,6 +1,12 @@
{ pkgs }:
let zbar = pkgs.mypkgs.zbar.override { enableVideo = false; };
in pkgs.writeShellScriptBin "qrclip" ''
set -eo pipefail
${pkgs.pngpaste}/bin/pngpaste - | ${zbar}/bin/zbarimg --raw -q1 -
''
{
pkgs,
lib,
stdenv,
}: let
zbar = pkgs.mypkgs.zbar.override {enableVideo = false;};
in
(pkgs.writeShellScriptBin "qrclip" ''
set -eo pipefail
${pkgs.pngpaste}/bin/pngpaste - | ${zbar}/bin/zbarimg --raw -q1 -
'')
// {meta.platforms = lib.platforms.darwin;}