Skip to content

Commit

Permalink
Add tools for updating flake inputs. Update inputs. Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
LukeChannings committed Jan 26, 2025
1 parent c24f570 commit 414f9ae
Show file tree
Hide file tree
Showing 11 changed files with 116 additions and 66 deletions.
8 changes: 3 additions & 5 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

## Maintenance

### Updating Nixpkgs
### Keeping dependencies up-to-date

1. Find the latest successful [Hydra build](https://status.nixos.org) for a nixpkgs channel
2. Update the input to that revision
- [With a workflow](https://github.com/LukeChannings/dotfiles/actions/workflows/update-inputs.yaml)
- Or manually with `nix flake update --override-input nixpkgs github:NixOS/nixpkgs/<rev>`
- `./scripts/update-flake-inputs.sh` – update inputs, using the latest nixpkgs Hydra build.
- `./scripts/diff-flake-lock.pl` – print updated inputs in the lockfile with github compare links

### Switching between a local clone and the git repo

Expand Down
6 changes: 3 additions & 3 deletions config/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ let
inputs ? inputs,
osModules ? builtins.attrValues darwinModules,
sharedHomeModules ? builtins.attrValues homeModules,
userHomeModule ? {},
userHomeModule ? { },
}:
(
let
Expand All @@ -207,14 +207,14 @@ let
}

(
{ lib, ... }:
{ ... }:
{
config =
if (user != null) then
(
assert user ? name;
{
users.users.${user.name} = {};
users.users.${user.name} = { };
home-manager.users.${user.name} = userHomeModule;
}
)
Expand Down
2 changes: 1 addition & 1 deletion config/git/home.nix
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ with lib;
};
}
{
home.packages = [pkgs.git-filter-repo];
home.packages = [ pkgs.git-filter-repo ];
}
(lib.mkIf (config.programs.git.signingInclude != null) {

Expand Down
1 change: 1 addition & 0 deletions devenv.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
programs.shellcheck.enable = true;
programs.yamlfmt.enable = true;
programs.actionlint.enable = true;
programs.perltidy.enable = true;
};

devenv.shells.default = {
Expand Down
95 changes: 46 additions & 49 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";

lix-module.url = "https://git.lix.systems/lix-project/nixos-module/archive/2.91.1-2.tar.gz";
# See https://lix.systems/add-to-config/#flake-based-configurations for the latest version
lix-module.url = "https://git.lix.systems/lix-project/nixos-module/archive/2.92.0.tar.gz";
lix-module.inputs.nixpkgs.follows = "nixpkgs";

nix-index-database.url = "github:nix-community/nix-index-database";
Expand Down
4 changes: 3 additions & 1 deletion modules/flakeModules/colmena.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ in
freeformType = types.lazyAttrsOf types.raw;

options.meta = mkOption {
type = types.submodule (metaOptions { inherit lib; });
type = types.submodule (metaOptions {
inherit lib;
});
default = { };
};
};
Expand Down
40 changes: 40 additions & 0 deletions scripts/diff-flake-lock.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#! /usr/bin/env nix-shell
#! nix-shell -i perl --packages perlPackages.JSON

use strict;
use warnings;

use JSON;

use Term::ANSIColor;
use File::Slurp;
use Time::Piece;

# Decode the lock files
my $old_lock = decode_json `git show HEAD:flake.lock`;
my $new_lock = decode_json(read_file('flake.lock'));

print "\n";

foreach my $key (keys %{$new_lock->{nodes}}) {
if (
exists $old_lock->{nodes}{$key} &&
exists $new_lock->{nodes}{$key}{locked} &&
defined $old_lock->{nodes}{$key}{locked}{type} &&
defined $old_lock->{nodes}{$key}{locked}{rev} &&
$new_lock->{nodes}{$key}{locked}{type} eq "github"
) {
my $new = $new_lock->{nodes}{$key}{locked};
my $old = $old_lock->{nodes}{$key}{locked};

# Compare 'rev' values
if ($new->{rev} ne $old->{rev}) {
my $old_modified_date = localtime($old->{lastModified});
my $days_since_modified = int(($new->{lastModified} - $old->{lastModified}) / (60 * 60 * 24));

print color('bold'), "Updated input '$key':", color('reset'), "\n";
print "Last modified: " . $old_modified_date->strftime("%d-%m-%Y") . " ($days_since_modified days ago)" . "\n";
print "Compare: " . color('blue') . "https://github.com/$new->{owner}/$new->{repo}/compare/$old->{rev}...$new->{rev}?diff=unified&w=" . color("reset") . "\n\n";
}
}
}
11 changes: 11 additions & 0 deletions scripts/update-flake-inputs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#! /usr/bin/env nix-shell
#! nix-shell -i bash --packages curl jq

set -x

NIXPKGS_REV="$( \
curl -s "https://prometheus.nixos.org/api/v1/query?query=channel_revision" | \
jq -r '.data.result[] | select(.metric.channel == "nixpkgs-unstable") | .metric.revision'\
)"

nix flake update --override-input nixpkgs "github:NixOS/nixpkgs/${NIXPKGS_REV}"
2 changes: 1 addition & 1 deletion templates/dev-fe-typescript/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
console.log("Hello world")
console.log("Hello world");
10 changes: 5 additions & 5 deletions templates/dev-fe-typescript/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"compilerOptions": {
"target": "esnext",
"module": "nodenext",
"allowImportingTsExtensions": true,
"rewriteRelativeImportExtensions": true,
"verbatimModuleSyntax": true
"target": "esnext",
"module": "nodenext",
"allowImportingTsExtensions": true,
"rewriteRelativeImportExtensions": true,
"verbatimModuleSyntax": true
}
}

0 comments on commit 414f9ae

Please # to comment.