Flakyfies and removes program updater service
This commit is contained in:
parent
8fa2b9b523
commit
7c26bd3685
19
README.md
19
README.md
|
@ -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
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
nix-collect-garbage -d --delete-old
|
10
bin/install
10
bin/install
|
@ -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
|
|
@ -1,4 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
nix-channel --update
|
||||
home-manager switch
|
|
@ -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": 1664172134,
|
||||
"narHash": "sha256-1Rx17Y/NgPQR4ibMnsZ/1UCnNbkx6vZz43IKfESxcCA=",
|
||||
"owner": "PatrickF1",
|
||||
"repo": "fzf.fish",
|
||||
"rev": "1a0bf6c66ce37bfb0b4b0d96d14e958445c21448",
|
||||
"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": 1664573442,
|
||||
"narHash": "sha256-AovlSIuJfMf8n9QLNUVtsCul+NVHIoen7APH2fLls3k=",
|
||||
"owner": "nix-community",
|
||||
"repo": "home-manager",
|
||||
"rev": "a7f0cc2d7b271b4a5df9b9e351d556c172f7e903",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "home-manager",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1664497144,
|
||||
"narHash": "sha256-oLTtXSp95umHunc+uFyGxUiZCXQlGFjXMz+w95hGZi4=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "671fabc93b4d1a3b38499c7b20776477c91b2b15",
|
||||
"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
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
{
|
||||
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 ];
|
||||
};
|
||||
};
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
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: && _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
|
42
launchd.nix
42
launchd.nix
|
@ -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";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
2
nix.nix
2
nix.nix
|
@ -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;
|
||||
|
|
|
@ -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";
|
||||
}]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ config, pkgs, ... }:
|
||||
{ inputs, config, pkgs, ... }:
|
||||
|
||||
{
|
||||
imports = [ ./fish.nix ./git.nix ./starship.nix ./vscode.nix ];
|
||||
|
@ -42,12 +42,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 = {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
];
|
||||
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
(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
|
Loading…
Reference in New Issue