Compare commits

...

7 Commits

Author SHA1 Message Date
Abhinav Sarkar ad62bfc6c9 flake.lock: Update
Flake lock file updates:

• Updated input 'fish-plugin-fzf':
    'github:PatrickF1/fzf.fish/1a0bf6c66ce37bfb0b4b0d96d14e958445c21448' (2022-09-26)
  → 'github:PatrickF1/fzf.fish/25752b6faf78b2050b0884a0682065231e8030fb' (2022-10-04)
• Updated input 'home-manager':
    'github:nix-community/home-manager/a7f0cc2d7b271b4a5df9b9e351d556c172f7e903' (2022-09-30)
  → 'github:nix-community/home-manager/1a8e35d2e53ed2ccd9818fad9c9478d56c655661' (2022-10-05)
• Updated input 'nixpkgs':
    'github:nixos/nixpkgs/a62844b302507c7531ad68a86cb7aa54704c9cb4' (2022-10-02)
  → 'github:nixos/nixpkgs/b7a47253e0c8cb04c0a3f8ed3149e90229e62884' (2022-10-04)
2022-10-06 10:30:38 +05:30
Abhinav Sarkar 1870b70926 Adds new programs 2022-10-05 23:16:17 +05:30
Abhinav Sarkar eef3b7c412 flake.lock: Update
Flake lock file updates:

• Updated input 'nixpkgs':
    'github:nixos/nixpkgs/14c5d226877aa90f656895ab7ab2badc4af03268' (2022-10-01)
  → 'github:nixos/nixpkgs/a62844b302507c7531ad68a86cb7aa54704c9cb4' (2022-10-02)
2022-10-03 09:55:22 +05:30
Abhinav Sarkar aca77387f5 flake.lock: Update
Flake lock file updates:

• Updated input 'nixpkgs':
    'github:nixos/nixpkgs/c6b3881520feb0c837cf5ae16d95d32277f41f60' (2022-09-30)
  → 'github:nixos/nixpkgs/14c5d226877aa90f656895ab7ab2badc4af03268' (2022-10-01)
2022-10-02 10:48:54 +05:30
Abhinav Sarkar 592d90aed3 Adds support for updating VSCode extensions from marketplace 2022-10-01 23:55:27 +05:30
Abhinav Sarkar a880535e50 flake.lock: Update
Flake lock file updates:

• Updated input 'nixpkgs':
    'github:nixos/nixpkgs/671fabc93b4d1a3b38499c7b20776477c91b2b15' (2022-09-30)
  → 'github:nixos/nixpkgs/c6b3881520feb0c837cf5ae16d95d32277f41f60' (2022-09-30)
2022-10-01 19:53:59 +05:30
Abhinav Sarkar 15bea6bdb1 Flakyfies and removes program updater service 2022-10-01 12:13:38 +05:30
16 changed files with 425 additions and 142 deletions

1
.envrc Normal file
View File

@ -0,0 +1 @@
use flake;

View File

@ -4,23 +4,32 @@ This is the [Nix] and [Home Manager] configuration for managing my MacBook.
## Usage
First install [Nix]. To install `home-manager` and set up the MacBook as per the config, run:
First install [Nix]. Then, in the repo directory, run `nix develop` to get into the Nix shell.
To set up the MacBook as per the config, run:
```bash
bin/install
just switch
```
To update installed packages, run:
```bash
bin/update
just update
```
To cleanup garbage, run:
To clean up garbage, run:
```bash
bin/cleanup
just clean
```
If you have [`just`] installed, you can also run these commands from any other directory, without starting Nix shell:
```bash
just <repo_dir>/switch # or update or clean
```
[Nix]: https://nixos.org
[Home Manager]: https://github.com/nix-community/home-manager
[`just`]: https://just.systems

View File

@ -1,3 +0,0 @@
#!/bin/bash
nix-collect-garbage -d --delete-old

View File

@ -1,10 +0,0 @@
#!/bin/bash
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
ROOT_DIR=$( dirname "$SCRIPT_DIR" )
mkdir -p "$HOME/.config/nixpkgs"
ln -f -s "$ROOT_DIR/home.nix" "$HOME/.config/nixpkgs/home.nix"
nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager
nix-channel --update
export NIX_PATH=$HOME/.nix-defexpr/channels:/nix/var/nix/profiles/per-user/root/channels${NIX_PATH:+:$NIX_PATH}
nix-shell '<home-manager>' -A install

View File

@ -1,4 +0,0 @@
#!/bin/bash
nix-channel --update
home-manager switch

132
flake.lock Normal file
View File

@ -0,0 +1,132 @@
{
"nodes": {
"dm-mono-font": {
"flake": false,
"locked": {
"lastModified": 1586946937,
"narHash": "sha256-Xj6UmvH7tqW6xdobBxuafqc7TB1nrTFwHWv4DaZmwx8=",
"owner": "googlefonts",
"repo": "dm-mono",
"rev": "57fadabfb200a77de2812540026c249dc3013077",
"type": "github"
},
"original": {
"owner": "googlefonts",
"repo": "dm-mono",
"type": "github"
}
},
"fish-plugin-foreign-env": {
"flake": false,
"locked": {
"lastModified": 1649621402,
"narHash": "sha256-3h03WQrBZmTXZLkQh1oVyhv6zlyYsSDS7HTHr+7WjY8=",
"owner": "oh-my-fish",
"repo": "plugin-foreign-env",
"rev": "b3dd471bcc885b597c3922e4de836e06415e52dd",
"type": "github"
},
"original": {
"owner": "oh-my-fish",
"repo": "plugin-foreign-env",
"type": "github"
}
},
"fish-plugin-fzf": {
"flake": false,
"locked": {
"lastModified": 1664920050,
"narHash": "sha256-POSMuip0w3iowQiablxIihFV1UWYKf5kRFY/Z3zjbwE=",
"owner": "PatrickF1",
"repo": "fzf.fish",
"rev": "25752b6faf78b2050b0884a0682065231e8030fb",
"type": "github"
},
"original": {
"owner": "PatrickF1",
"repo": "fzf.fish",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1650374568,
"narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "b4a34015c698c7793d592d66adbab377907a2be8",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"home-manager": {
"inputs": {
"nixpkgs": [
"nixpkgs"
],
"utils": "utils"
},
"locked": {
"lastModified": 1664983332,
"narHash": "sha256-KyQvgFRwk3qW3Qr+lO5UDqfpST/HaCJY1yB7wPgPUqo=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "1a8e35d2e53ed2ccd9818fad9c9478d56c655661",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "home-manager",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1664904529,
"narHash": "sha256-mGlB/SQR4E9jb7fOOxCTJlwL6Mk1Dpyvi4UrOXL6C18=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "b7a47253e0c8cb04c0a3f8ed3149e90229e62884",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"dm-mono-font": "dm-mono-font",
"fish-plugin-foreign-env": "fish-plugin-foreign-env",
"fish-plugin-fzf": "fish-plugin-fzf",
"flake-compat": "flake-compat",
"home-manager": "home-manager",
"nixpkgs": "nixpkgs"
}
},
"utils": {
"locked": {
"lastModified": 1659877975,
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

48
flake.nix Normal file
View File

@ -0,0 +1,48 @@
{
description = "Home Manager configuration of Abhinav Sarkar";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
dm-mono-font = {
url = "github:googlefonts/dm-mono";
flake = false;
};
fish-plugin-foreign-env = {
url = "github:oh-my-fish/plugin-foreign-env";
flake = false;
};
fish-plugin-fzf = {
url = "github:PatrickF1/fzf.fish";
flake = false;
};
};
outputs = inputs@{ nixpkgs, home-manager, ... }:
let
system = "x86_64-darwin";
pkgs = import nixpkgs {
inherit system;
config = { allowUnfree = true; };
};
in {
homeConfigurations.abhinav = home-manager.lib.homeManagerConfiguration {
inherit pkgs;
modules = [ ./home.nix ];
extraSpecialArgs = { inherit inputs; };
};
devShells.${system}.default = pkgs.mkShell {
buildInputs = with pkgs; [ (import home-manager { inherit pkgs; }).home-manager just ];
shellHook = ''
export NIXPKGS_PATH=${pkgs.path};
'';
};
};
}

44
justfile Normal file
View File

@ -0,0 +1,44 @@
in_nix_shell := if env_var_or_default("IN_NIX_SHELL", "false") == "false" { "false" } else { "true" }
root_dir := justfile_directory()
# choose a just command to run
default:
@just --choose
# show available just commands
help:
@just --list --unsorted --list-heading $'Available commands:\n'
_run cmd:
#!/usr/bin/env -S sh -eu
if [ "{{ in_nix_shell }}" = "true" ]; then
just "{{ root_dir }}/{{ cmd }}"
else
nix-shell "{{ root_dir }}/shell.nix" --run "just \"{{ root_dir }}/{{ cmd }}\""
fi
_build:
home-manager build --flake "{{ root_dir }}#abhinav"
# build latest home-manager generation
build: (_run "_build")
_switch:
home-manager switch --flake "{{ root_dir }}#abhinav"
# switch to latest home-manager generation
switch: (_run "_switch")
_update-vscode-extensions:
$NIXPKGS_PATH/pkgs/applications/editors/vscode/extensions/update_installed_exts.sh > \
{{ root_dir }}/programs/vscode/extensions.nix
_update: _update-vscode-extensions && _switch
nix flake update --commit-lock-file "{{ root_dir }}"
# update packages and switch
update: (_run "_update")
# clean up nix garbage
clean:
nix-collect-garbage -d --delete-old

View File

@ -1,46 +1,22 @@
{ config, pkgs, lib, ... }:
let binDir = "${config.home.profileDirectory}/bin";
let
binPath = "${pkgs.coreutils-full}/bin";
dyndns-updater-script = pkgs.writeScript "dyndns-updater" ''
#!${pkgs.bash}/bin/bash
export CLOUDFLARE_API_TOKEN=`${binPath}/cat ${config.xdg.configHome}/.cloudflare_dns_updater_api_token`
${binPath}/echo && ${binPath}/date
${pkgs.cloudflare-dyndns}/bin/cloudflare-dyndns --debug home.abhinavsarkar.net
'';
in {
launchd.agents.dyndns-updater = lib.optionalAttrs pkgs.stdenv.hostPlatform.isDarwin {
enable = true;
config = {
Program = "${pkgs.cloudflare-dyndns}/bin/cloudflare-dyndns";
ProgramArguments = [
"${pkgs.cloudflare-dyndns}/bin/cloudflare-dyndns"
"--api-token"
(builtins.readFile ./.cloudflare_dns_updater_api_token)
"--debug"
"home.abhinavsarkar.net"
];
Program = "${dyndns-updater-script}";
StandardErrorPath = "/tmp/hm-dyndns-updater.log";
StandardOutPath = "/tmp/hm-dyndns-updater.log";
StartInterval = 600;
ProcessType = "Background";
};
};
launchd.agents.program-updater = lib.optionalAttrs pkgs.stdenv.hostPlatform.isDarwin {
enable = true;
config = {
Program = "${binDir}/bash";
ProgramArguments = [
"${binDir}/bash"
"-c"
''echo && date && \
export PATH="${binDir}:$PATH" && echo $PATH && \
nix-channel --update && \
home-manager switch &&
nix-collect-garbage -d --delete-old
''
];
StandardErrorPath = "/tmp/hm-program-updater.log";
StandardOutPath = "/tmp/hm-program-updater.log";
StartCalendarInterval = [{
Hour = 10;
Minute = 30;
}];
ProcessType = "Background";
};
};
}

View File

@ -4,7 +4,7 @@
nixpkgs.config.allowUnfree = true;
nix.package = pkgs.nixUnstable;
nix.settings = {
experimental-features = "nix-command flakes";
experimental-features = "nix-command flakes repl-flake";
max-jobs = 6;
cores = 2;
auto-optimise-store = true;

View File

@ -1,25 +1,6 @@
{ lib, fetchzip }:
{ dm-mono-src, lib, pkgs }:
let
pname = "dm-mono";
version = "1.0.0";
in fetchzip {
name = "${pname}-${version}";
extension = "zip";
stripRoot = false;
url = "https://fonts.google.com/download?family=DM%20Mono";
hash = "sha256-HAStsW+SAAkOjywPBSzhmib+fEylWZo6PtNtfDVNYZ0=";
postFetch = ''
mkdir -p $out/share/fonts/truetype
mv $out/*.ttf $out/share/fonts/truetype
'';
meta = with lib; {
description = "DM Mono";
homepage = "https://github.com/googlefonts/dm-mono";
license = licenses.ofl;
platforms = platforms.all;
};
}
pkgs.linkFarm "dm-mono" [{
name = "share/fonts/truetype";
path = "${dm-mono-src}/exports";
}]

View File

@ -1,4 +1,4 @@
{ config, pkgs, ... }:
{ inputs, config, pkgs, ... }:
{
imports = [ ./fish.nix ./git.nix ./starship.nix ./vscode.nix ];
@ -27,6 +27,7 @@
nix
nix-diff
nixfmt
proselint
ranger
rnix-lsp
shellcheck
@ -42,12 +43,10 @@
nanum-gothic-coding
roboto-mono
source-code-pro
(import ../packages/dm-mono.nix { inherit lib fetchzip; })
(import ../packages/dm-mono.nix { inherit lib pkgs; dm-mono-src = "${inputs.dm-mono-font}"; })
(nerdfonts.override { fonts = [ "Monoid" "Agave" "Iosevka" "Lekton" "VictorMono" ]; })
];
programs.home-manager.enable = true;
programs.htop = {
enable = true;
settings = {

View File

@ -1,4 +1,4 @@
{ config, pkgs, ... }:
{ inputs, config, pkgs, ... }:
{
programs.fish = {
@ -7,21 +7,11 @@
plugins = [
{
name = "foreign-env";
src = pkgs.fetchFromGitHub {
owner = "oh-my-fish";
repo = "plugin-foreign-env";
rev = "b3dd471bcc885b597c3922e4de836e06415e52dd";
sha256 = "00xqlyl3lffc5l0viin1nyp819wf81fncqyz87jx8ljjdhilmgbs";
};
src = inputs.fish-plugin-foreign-env;
}
{
name = "fzf";
src = pkgs.fetchFromGitHub {
owner = "PatrickF1";
repo = "fzf.fish";
rev = "2bb6f712b0b99fc5cc40ca78b6b3ba8b2529b0f7";
hash = "sha256-XmRGe39O3xXmTvfawwT2mCwLIyXOlQm7f40mH5tzz+s=";
};
src = inputs.fish-plugin-fzf;
}
];

View File

@ -1,6 +1,15 @@
{ config, pkgs, ... }:
{
let
marketplaceExtensions = [
"13xforever/language-x86-64-assembly"
"ban/spellright"
"dawhite/mustache"
"kirozen/wordcounter"
"pedrorgirardi/vscode-cljfmt"
"wmaurer/change-case"
];
in {
programs.vscode = {
enable = true;
mutableExtensionsDir = false;
@ -13,6 +22,7 @@
esbenp.prettier-vscode
haskell.haskell
jdinhlife.gruvbox
jebbs.plantuml
jnoortheen.nix-ide
justusadam.language-haskell
kamikillerto.vscode-colorize
@ -23,50 +33,9 @@
timonwong.shellcheck
tyriar.sort-lines
zhuangtongfa.material-theme
] ++ pkgs.vscode-utils.extensionsFromVscodeMarketplace [
{
publisher = "13xforever";
name = "language-x86-64-assembly";
version = "3.0.0";
sha256 = "sha256-wIsY6Fuhs676EH8rSz4fTHemVhOe5Se9SY3Q9iAqr1M=";
}
{
publisher = "ban";
name = "spellright";
version = "3.0.90";
sha256 = "sha256-yAHlwX2stqGuUu3Q+mVxsF1JKmTgy/kkT63VH3YlomM=";
}
{
publisher = "dawhite";
name = "mustache";
version = "1.1.1";
sha256 = "sha256-PkymMex1icvDN2Df38EIuV1O9TkMNWP2sGOjl1+xGMk=";
}
{
publisher = "jebbs";
name = "plantuml";
version = "2.17.4";
sha256 = "sha256-fnz6ubB73i7rJcv+paYyNV1r4cReuyFPjgPM0HO40ug";
}
{
publisher = "kirozen";
name = "wordcounter";
version = "2.4.3";
sha256 = "sha256-gkdMaMiDwQNjmrGfUK/c/bQUn1bovESRPJ+etz2yfJk=";
}
{
publisher = "pedrorgirardi";
name = "vscode-cljfmt";
version = "1.3.0";
sha256 = "sha256-gZ8Fo7YXSapnQL6UbYUKJDg27wYqK2NG1lcJUae6dWs=";
}
{
publisher = "wmaurer";
name = "change-case";
version = "1.0.0";
sha256 = "sha256-tN/jlG2PzuiCeERpgQvdqDoa3UgrUaM7fKHv6KFqujc=";
}
];
] ++ pkgs.vscode-utils.extensionsFromVscodeMarketplace (builtins.filter
({ publisher, name, ... }: builtins.elem (publisher + "/" + name) marketplaceExtensions)
(import ./vscode/extensions.nix).extensions);
userSettings = {
debug.console.fontSize = 13;

View File

@ -0,0 +1,141 @@
{ extensions = [
{
name = "language-x86-64-assembly";
publisher = "13xforever";
version = "3.0.0";
sha256 = "0lxg58hgdl4d96yjgrcy2dbacxsc3wz4navz23xaxcx1bgl1i2y0";
}
{
name = "spellright";
publisher = "ban";
version = "3.0.90";
sha256 = "0qx24mv1zmdd9wjgkjz0chm4jpdhf5jzml7daapa3dmcgp0ya0f8";
}
{
name = "markdown-mermaid";
publisher = "bierner";
version = "1.15.2";
sha256 = "0wq15fviv2zxn58xbgzwh8x958iy24q0963pbrci732hnyb9s9m8";
}
{
name = "better-toml";
publisher = "bungcip";
version = "0.3.2";
sha256 = "08lhzhrn6p0xwi0hcyp6lj9bvpfj87vr99klzsiy8ji7621dzql3";
}
{
name = "vscode-markdownlint";
publisher = "DavidAnson";
version = "0.48.1";
sha256 = "0npmvaw734r8pk17cz8vccxwxnbpk076ickndkd9gymcyqd5jfnx";
}
{
name = "mustache";
publisher = "dawhite";
version = "1.1.1";
sha256 = "1j8qn5grg8v3n3v66d8c77slwpdr130xzpv06z1wp2bmxhqsck1y";
}
{
name = "prettier-vscode";
publisher = "esbenp";
version = "9.9.0";
sha256 = "1zba2k51ylpzz47r74kdr2adp669xw19a866gw0wndcigkhcrgk2";
}
{
name = "haskell";
publisher = "haskell";
version = "2.2.1";
sha256 = "14p9g07zsb3da4ilaasgsdvh3wagfzayqr8ichsf6k5c952zi8fk";
}
{
name = "gruvbox";
publisher = "jdinhlife";
version = "1.8.0";
sha256 = "0bixrlhimy0qw94cy354fn0gcsb8s1y4m4yf1gkncaawqinmp09z";
}
{
name = "plantuml";
publisher = "jebbs";
version = "2.17.4";
sha256 = "1s6jp1rx1k03ir7j3fsyqkhnnp9m6akabznb4pmjxpkvn2wzlz3y";
}
{
name = "nix-ide";
publisher = "jnoortheen";
version = "0.1.23";
sha256 = "0i5zqfz2ic57z9b4v6mrs68dzhvgpnr5984srjapi0nzm30k127b";
}
{
name = "language-haskell";
publisher = "justusadam";
version = "3.6.0";
sha256 = "115y86w6n2bi33g1xh6ipz92jz5797d3d00mr4k8dv5fz76d35dd";
}
{
name = "vscode-colorize";
publisher = "kamikillerto";
version = "0.11.1";
sha256 = "1h82b1jz86k2qznprng5066afinkrd7j3738a56idqr3vvvqnbsm";
}
{
name = "wordcounter";
publisher = "kirozen";
version = "2.4.3";
sha256 = "16bwn8yvg7lz7j8l9g78asgi9d7xvjpm17xik9ih7hc3r1l4qiw2";
}
{
name = "git-graph";
publisher = "mhutchie";
version = "1.30.0";
sha256 = "000zhgzijf3h6abhv4p3cz99ykj6489wfn81j0s691prr8q9lxxh";
}
{
name = "vscode-cljfmt";
publisher = "pedrorgirardi";
version = "1.3.0";
sha256 = "0svmpakm22apsr366ara0vpkcf141a2nv55y81kslj8pnsihb7w1";
}
{
name = "rust-analyzer";
publisher = "rust-lang";
version = "0.4.1233";
sha256 = "1rna5l6n8xrznj69ywwnhz8im22lvmzlj6qbz4j7282phkqrj9zf";
}
{
name = "just";
publisher = "skellock";
version = "2.0.0";
sha256 = "1ph869zl757a11f8iq643f79h8gry7650a9i03mlxyxlqmspzshl";
}
{
name = "code-spell-checker";
publisher = "streetsidesoftware";
version = "2.10.1";
sha256 = "03cx684mn0nk47xpm46dly8g0lxars5h46vj41p8nhgsq9429rhm";
}
{
name = "shellcheck";
publisher = "timonwong";
version = "0.23.0";
sha256 = "190xi23kad95bbh8cwk5asnncfdaqi9574hv87ja5lpy53my1v8d";
}
{
name = "sort-lines";
publisher = "Tyriar";
version = "1.9.1";
sha256 = "0dds99j6awdxb0ipm15g543a5b6f0hr00q9rz961n0zkyawgdlcb";
}
{
name = "change-case";
publisher = "wmaurer";
version = "1.0.0";
sha256 = "0dxsdahyivx1ghxs6l9b93filfm8vl5q2sa4g21fiklgdnaf7pxl";
}
{
name = "material-theme";
publisher = "zhuangtongfa";
version = "3.15.5";
sha256 = "0crrzpdy8fy4l1nim93qscmlpz2jhyb6hf0gh1rzqgfnk9w431xi";
}
];
}

10
shell.nix Normal file
View File

@ -0,0 +1,10 @@
(import
(
let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in
fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}
)
{ src = ./.; }
).shellNix