diff --git a/.envrc b/.envrc new file mode 100644 index 00000000..3550a30f --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.github/workflows/nix.yaml b/.github/workflows/nix.yaml new file mode 100644 index 00000000..74139956 --- /dev/null +++ b/.github/workflows/nix.yaml @@ -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 diff --git a/.gitignore b/.gitignore index 86d28992..091ed68f 100644 --- a/.gitignore +++ b/.gitignore @@ -23,10 +23,15 @@ lua/libimlib2.c # Compiler cache .cache -# Ignore vscode stuff -.vscode +# Ignore (most) vscode stuff +.vscode/* *.code-workspace +# Allow vscode recommended extensions +!.vscode/extensions.json .idea/ # Ignore nix stuff /result + +# Ignore direnv +.direnv diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 00000000..69944203 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,7 @@ +{ + "recommendations": [ + "kamadorueda.alejandra", + "ms-vscode.cmake-tools", + "mkhl.direnv" + ] +} diff --git a/flake.lock b/flake.lock index 09f0e44d..b226defb 100644 --- a/flake.lock +++ b/flake.lock @@ -1,12 +1,15 @@ { "nodes": { "flake-utils": { + "inputs": { + "systems": "systems" + }, "locked": { - "lastModified": 1676283394, - "narHash": "sha256-XX2f9c3iySLCw54rJ/CZs+ZK6IQy7GXNY4nSOyu2QG4=", + "lastModified": 1687171271, + "narHash": "sha256-BJlq+ozK2B1sJDQXS3tzJM5a+oVZmi1q0FlBK/Xqv7M=", "owner": "numtide", "repo": "flake-utils", - "rev": "3db36a8b464d0c4532ba1c7dda728f4576d6d073", + "rev": "abfb11bd1aec8ced1c9bb9adfe68018230f4fb3c", "type": "github" }, "original": { @@ -17,11 +20,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1677407201, - "narHash": "sha256-3blwdI9o1BAprkvlByHvtEm5HAIRn/XPjtcfiunpY7s=", + "lastModified": 1687502512, + "narHash": "sha256-dBL/01TayOSZYxtY4cMXuNCBk8UMLoqRZA+94xiFpJA=", "owner": "nixos", "repo": "nixpkgs", - "rev": "7f5639fa3b68054ca0b062866dc62b22c3f11505", + "rev": "3ae20aa58a6c0d1ca95c9b11f59a2d12eebc511f", "type": "github" }, "original": { @@ -36,6 +39,21 @@ "flake-utils": "flake-utils", "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", diff --git a/flake.nix b/flake.nix index 9b433aff..b30a9648 100644 --- a/flake.nix +++ b/flake.nix @@ -1,5 +1,5 @@ { - description = "A Nix flake for Conky"; + description = "A Nix flake for Conky, including a dev shell"; inputs = { nixpkgs = { @@ -10,53 +10,77 @@ }; }; - outputs = { self, nixpkgs, flake-utils, ... }: flake-utils.lib.eachDefaultSystem - (system: - let + outputs = { + self, + nixpkgs, + flake-utils, + ... + }: + flake-utils.lib.eachDefaultSystem + ( + system: let pkgs = import nixpkgs { inherit system; - overlays = [ self.overlay ]; + overlays = [self.overlay]; }; in - rec - { - packages = flake-utils.lib.flattenTree { - conky = pkgs.conky; - }; - defaultPackage = packages.conky; - apps.conky = flake-utils.lib.mkApp { drv = packages.conky; }; - defaultApp = apps.conky; - } - ) // { - overlay = final: prev: { - conky = with final; stdenv.mkDerivation rec { - name = "conky"; - src = ./.; - nativeBuildInputs = [ - clang_15 - cmake - git - ninja - pkg-config - ]; - buildInputs = [ - freetype - gettext - imlib2 - llvmPackages_15.libcxx - llvmPackages_15.libcxxabi - lua5_4 - ncurses - xorg.libICE - xorg.libSM - xorg.libX11 - xorg.libXext - xorg.libXft - xorg.libXinerama - xorg.libXdamage - xorg.libXfixes - ]; + with pkgs; rec + { + packages = flake-utils.lib.flattenTree { + conky = conky; + }; + + defaultPackage = packages.conky; + apps.conky = flake-utils.lib.mkApp {drv = packages.conky;}; + defaultApp = apps.conky; + devShells.default = mkShell { + buildInputs = + packages.conky.buildInputs + ++ packages.conky.nativeBuildInputs + ++ [ + alejandra # for beautifying flake + lefthook # for git hooks + nodejs # for web/ stuff + # for docs + (python3.withPackages (ps: with ps; [jinja2])) + ]; + }; + } + ) + // { + overlay = final: prev: { + conky = with final; + stdenv.mkDerivation rec { + name = "conky"; + src = ./.; + nativeBuildInputs = [ + clang_16 + cmake + git + llvmPackages_16.clang-unwrapped + ninja + pkg-config + ]; + 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; + }; }; }; - }; } diff --git a/lefthook.yml b/lefthook.yml index d44bb37b..da076d38 100644 --- a/lefthook.yml +++ b/lefthook.yml @@ -17,3 +17,8 @@ pre-commit: npx prettier --write {staged_files} \ && git add {staged_files} glob: '*.{md,json,yml,yaml}' + nix-linter: + run: | + alejandra -q {staged_files} \ + && git add {staged_files} + glob: '*.{nix}'