Add nix flake dev shell, direnv, VSCode extensions, CI

This commit is contained in:
Brenden Matthews 2023-06-24 12:51:09 -04:00
parent eb1649a129
commit 4940070c0a
7 changed files with 146 additions and 52 deletions

1
.envrc Normal file
View File

@ -0,0 +1 @@
use flake

34
.github/workflows/nix.yaml vendored Normal file
View File

@ -0,0 +1,34 @@
name: 'Nix build'
on:
push:
branches:
- main
paths-ignore:
- web/**
- doc/**
pull_request:
branches:
- main
paths-ignore:
- web/**
- doc/**
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-and-check:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v22
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
- uses: cachix/cachix-action@v12
with:
name: conky
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- run: nix build
- run: nix flake check

9
.gitignore vendored
View File

@ -23,10 +23,15 @@ lua/libimlib2.c
# Compiler cache # Compiler cache
.cache .cache
# Ignore vscode stuff # Ignore (most) vscode stuff
.vscode .vscode/*
*.code-workspace *.code-workspace
# Allow vscode recommended extensions
!.vscode/extensions.json
.idea/ .idea/
# Ignore nix stuff # Ignore nix stuff
/result /result
# Ignore direnv
.direnv

7
.vscode/extensions.json vendored Normal file
View File

@ -0,0 +1,7 @@
{
"recommendations": [
"kamadorueda.alejandra",
"ms-vscode.cmake-tools",
"mkhl.direnv"
]
}

View File

@ -1,12 +1,15 @@
{ {
"nodes": { "nodes": {
"flake-utils": { "flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": { "locked": {
"lastModified": 1676283394, "lastModified": 1687171271,
"narHash": "sha256-XX2f9c3iySLCw54rJ/CZs+ZK6IQy7GXNY4nSOyu2QG4=", "narHash": "sha256-BJlq+ozK2B1sJDQXS3tzJM5a+oVZmi1q0FlBK/Xqv7M=",
"owner": "numtide", "owner": "numtide",
"repo": "flake-utils", "repo": "flake-utils",
"rev": "3db36a8b464d0c4532ba1c7dda728f4576d6d073", "rev": "abfb11bd1aec8ced1c9bb9adfe68018230f4fb3c",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -17,11 +20,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1677407201, "lastModified": 1687502512,
"narHash": "sha256-3blwdI9o1BAprkvlByHvtEm5HAIRn/XPjtcfiunpY7s=", "narHash": "sha256-dBL/01TayOSZYxtY4cMXuNCBk8UMLoqRZA+94xiFpJA=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "7f5639fa3b68054ca0b062866dc62b22c3f11505", "rev": "3ae20aa58a6c0d1ca95c9b11f59a2d12eebc511f",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -36,6 +39,21 @@
"flake-utils": "flake-utils", "flake-utils": "flake-utils",
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs"
} }
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
} }
}, },
"root": "root", "root": "root",

112
flake.nix
View File

@ -1,5 +1,5 @@
{ {
description = "A Nix flake for Conky"; description = "A Nix flake for Conky, including a dev shell";
inputs = { inputs = {
nixpkgs = { nixpkgs = {
@ -10,53 +10,77 @@
}; };
}; };
outputs = { self, nixpkgs, flake-utils, ... }: flake-utils.lib.eachDefaultSystem outputs = {
(system: self,
let nixpkgs,
flake-utils,
...
}:
flake-utils.lib.eachDefaultSystem
(
system: let
pkgs = import nixpkgs { pkgs = import nixpkgs {
inherit system; inherit system;
overlays = [ self.overlay ]; overlays = [self.overlay];
}; };
in in
rec with pkgs; rec
{ {
packages = flake-utils.lib.flattenTree { packages = flake-utils.lib.flattenTree {
conky = pkgs.conky; conky = conky;
}; };
defaultPackage = packages.conky;
apps.conky = flake-utils.lib.mkApp { drv = packages.conky; }; defaultPackage = packages.conky;
defaultApp = apps.conky; apps.conky = flake-utils.lib.mkApp {drv = packages.conky;};
} defaultApp = apps.conky;
) // { devShells.default = mkShell {
overlay = final: prev: { buildInputs =
conky = with final; stdenv.mkDerivation rec { packages.conky.buildInputs
name = "conky"; ++ packages.conky.nativeBuildInputs
src = ./.; ++ [
nativeBuildInputs = [ alejandra # for beautifying flake
clang_15 lefthook # for git hooks
cmake nodejs # for web/ stuff
git # for docs
ninja (python3.withPackages (ps: with ps; [jinja2]))
pkg-config ];
]; };
buildInputs = [ }
freetype )
gettext // {
imlib2 overlay = final: prev: {
llvmPackages_15.libcxx conky = with final;
llvmPackages_15.libcxxabi stdenv.mkDerivation rec {
lua5_4 name = "conky";
ncurses src = ./.;
xorg.libICE nativeBuildInputs = [
xorg.libSM clang_16
xorg.libX11 cmake
xorg.libXext git
xorg.libXft llvmPackages_16.clang-unwrapped
xorg.libXinerama ninja
xorg.libXdamage pkg-config
xorg.libXfixes ];
]; buildInputs =
[
freetype
gettext
imlib2
llvmPackages_16.libcxx
llvmPackages_16.libcxxabi
lua5_4
ncurses
xorg.libICE
xorg.libSM
xorg.libX11
xorg.libXdamage
xorg.libXext
xorg.libXfixes
xorg.libXft
xorg.libXinerama
]
++ lib.optional stdenv.isDarwin darwin.libobjc;
};
}; };
}; };
};
} }

View File

@ -17,3 +17,8 @@ pre-commit:
npx prettier --write {staged_files} \ npx prettier --write {staged_files} \
&& git add {staged_files} && git add {staged_files}
glob: '*.{md,json,yml,yaml}' glob: '*.{md,json,yml,yaml}'
nix-linter:
run: |
alejandra -q {staged_files} \
&& git add {staged_files}
glob: '*.{nix}'