Skip to content

Commit 5b5cc28

Browse files
authored
Merge pull request #219 from berquist/nix
Add Nix for pre-commit dependencies
2 parents 7919dfd + ebb65cc commit 5b5cc28

9 files changed

Lines changed: 224 additions & 8 deletions

File tree

.envrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
use flake

.github/workflows/ci.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,15 @@ concurrency:
1010
group: ci-${{github.ref}}-${{github.event.pull_request.number || github.run_number}}
1111
cancel-in-progress: true
1212

13+
permissions: {}
14+
1315
jobs:
1416
prechecks:
1517
uses: ./.github/workflows/pre-commit.yml
16-
all-prechecks:
17-
needs: [prechecks]
18+
nix:
19+
uses: ./.github/workflows/nix.yml
20+
all:
21+
needs: [prechecks, nix]
1822
runs-on: ubuntu-latest
1923
steps:
2024
- name: Success

.github/workflows/nix.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
name: build and test nix package
3+
4+
# yamllint disable-line rule:truthy
5+
on:
6+
workflow_dispatch:
7+
workflow_call:
8+
9+
concurrency:
10+
group: nix-${{github.ref}}-${{github.event.pull_request.number || github.run_number}}
11+
cancel-in-progress: true
12+
13+
permissions: {}
14+
15+
jobs:
16+
nix-build:
17+
runs-on: ubuntu-latest
18+
steps:
19+
# Install Nix on the runner
20+
- uses: cachix/install-nix-action@17fe5fb4a23ad6cbbe47d6b3f359611ad276644c # v31
21+
with:
22+
nix_path: nixpkgs=channel:nixos-unstable
23+
# Pull from the cachix cache
24+
- uses: cachix/cachix-action@0fc020193b5a1fa3ac4575aa3a7d3aa6a35435ad # v16
25+
with:
26+
name: cclib
27+
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
28+
# Checkout of the current head in the working dir
29+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
30+
with:
31+
persist-credentials: false
32+
- name: Check nix flake
33+
run: nix flake check -L

.github/workflows/pre-commit.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,17 @@ concurrency:
99
group: style-${{github.ref}}-${{github.event.pull_request.number || github.run_number}}
1010
cancel-in-progress: true
1111

12+
permissions: {}
13+
1214
jobs:
1315
pre-commit:
1416
runs-on: ubuntu-latest
1517
steps:
16-
- uses: actions/checkout@v4
17-
- uses: actions/setup-python@v5
18+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
19+
with:
20+
persist-credentials: false
21+
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
1822
- name: install dependencies for sorting regressionfiles.yaml
1923
run: |
2024
python -m pip install 'ruamel.yaml'
21-
- uses: pre-commit/action@v3.0.1
25+
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
*.pyc
2+
.direnv
23
.idea
4+
.venv
35

46
regressionfiles.diff
57
regressionfiles.yaml.orig

.pre-commit-config.yaml

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,47 @@ repos:
1313
- repo: https://github.com/pre-commit/pre-commit-hooks
1414
rev: "v5.0.0"
1515
hooks:
16+
- id: check-json
1617
- id: check-yaml
18+
- id: trailing-whitespace
19+
exclude: |
20+
(?x)(
21+
^ADF|
22+
^DALTON|
23+
^FChk|
24+
^GAMESS|
25+
^GAMESSDAT|
26+
^GAMESS-UK|
27+
^Gaussian|
28+
^io|
29+
^Jaguar|
30+
^Molcas|
31+
^Molpro|
32+
^MOPAC|
33+
^NBO|
34+
^NWChem|
35+
^ORCA|
36+
^Psi3|
37+
^Psi4|
38+
^QChem|
39+
^Turbomole|
40+
^XTB
41+
)
1742
- repo: local
1843
hooks:
1944
- id: sort-regressionfiles-yaml
2045
name: Sort regressionfiles.yaml
2146
entry: ./sort_regressionfiles_yaml.sh
2247
language: script
2348
files: ^regressionfiles\.yaml$
24-
- repo: https://github.com/Mateusz-Grzelinski/actionlint-py
25-
rev: "v1.7.7.23"
49+
- repo: https://github.com/rhysd/actionlint
50+
rev: "v1.7.7"
2651
hooks:
2752
- id: actionlint
53+
additional_dependencies:
54+
- "github.com/wasilibs/go-shellcheck/cmd/shellcheck@v0.10.0"
55+
- repo: https://github.com/zizmorcore/zizmor-pre-commit
56+
rev: "v1.9.0"
57+
hooks:
58+
- id: zizmor
59+
args: [--no-progress, --persona=pedantic]

flake.lock

Lines changed: 61 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
{
2+
description = "Parsers and algorithms for computational chemistry logfiles (regression data)";
3+
4+
inputs = {
5+
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
6+
flake-utils.url = "github:numtide/flake-utils";
7+
};
8+
9+
outputs =
10+
{
11+
self,
12+
nixpkgs,
13+
flake-utils,
14+
}:
15+
let
16+
/*
17+
Change this value ({major}.{min}) to
18+
update the Python virtual-environment
19+
version. When you do this, make sure
20+
to delete the `.venv` directory to
21+
have the hook rebuild it for the new
22+
version, since it won't overwrite an
23+
existing one. After this, reload the
24+
development shell to rebuild it.
25+
You'll see a warning asking you to
26+
do this when version mismatches are
27+
present. For safety, removal should
28+
be a manual step, even if trivial.
29+
*/
30+
version = "3.13";
31+
in
32+
flake-utils.lib.eachDefaultSystem (
33+
system:
34+
let
35+
pkgs = import nixpkgs { inherit system; };
36+
in
37+
{
38+
devShells.default =
39+
let
40+
concatMajorMinor =
41+
v:
42+
pkgs.lib.pipe v [
43+
pkgs.lib.versions.splitVersion
44+
(pkgs.lib.sublist 0 2)
45+
pkgs.lib.concatStrings
46+
];
47+
python = pkgs."python${concatMajorMinor version}";
48+
in
49+
pkgs.mkShellNoCC {
50+
venvDir = ".venv";
51+
52+
postShellHook = ''
53+
venvVersionWarn() {
54+
local venvVersion
55+
venvVersion="$("$venvDir/bin/python" -c 'import platform; print(platform.python_version())')"
56+
57+
[[ "$venvVersion" == "${python.version}" ]] && return
58+
59+
cat <<EOF
60+
Warning: Python version mismatch: [$venvVersion (venv)] != [${python.version}]
61+
Delete '$venvDir' and reload to rebuild for version ${python.version}
62+
EOF
63+
}
64+
65+
venvVersionWarn
66+
'';
67+
68+
packages = [
69+
pkgs.coreutils
70+
pkgs.diffutils
71+
pkgs.patch
72+
python.pkgs.pip
73+
python.pkgs.ruamel-yaml
74+
python.pkgs.venvShellHook
75+
];
76+
};
77+
}
78+
);
79+
}

renovate.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
33
"extends": [
4-
"config:recommended"
4+
"local>cclib/.github:renovate-config"
55
]
66
}

0 commit comments

Comments
 (0)