Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update/flake #166

Merged
merged 2 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ updates:
- package-ecosystem: "github-actions"
directory: "/"
commit-message:
prefix: ⬆️
prefix: "⬆️ "
schedule:
interval: "monthly"

- package-ecosystem: "cargo"
directory: "/"
commit-message:
prefix: ⬆️
prefix: "⬆️ "
schedule:
interval: "monthly"
34 changes: 16 additions & 18 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,31 @@
name: "ci"

on:
workflow_dispatch: # allows manual triggering
pull_request:
branches: [ main ]
branches: [main]
paths-ignore:
- '**.md'
push:
branches: [ main ]
branches: [main]
paths-ignore:
- '**.md'
merge_group:

jobs:
flake-check:
runs-on: ubuntu-latest
environment: cachix
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Nix Flakes doesn't work on shallow clones
- uses: cachix/install-nix-action@V27
with:
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- uses: cachix/cachix-action@v15
with:
name: friedow
# If you chose API tokens for write access OR if you have a private cache
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: "flake check"
run: nix flake check -Lvv --no-update-lock-file
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Nix Flakes doesn't work on shallow clones
- uses: cachix/install-nix-action@V27
with:
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- uses: cachix/cachix-action@v15
with:
name: friedow
# If you chose API tokens for write access OR if you have a private cache
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: "flake check"
run: nix flake check -Lvv --no-update-lock-file
36 changes: 18 additions & 18 deletions flake.lock

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

161 changes: 99 additions & 62 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

nixConfig = {
extra-substituters = [ "https://friedow.cachix.org" ];
extra-trusted-public-keys =
[ "friedow.cachix.org-1:JDEaYMqNgGu+bVPOca7Zu4Cp8QDMkvQpArKuwPKa29A=" ];
extra-trusted-public-keys = [ "friedow.cachix.org-1:JDEaYMqNgGu+bVPOca7Zu4Cp8QDMkvQpArKuwPKa29A=" ];
};

inputs = {
Expand All @@ -17,12 +16,24 @@
};
};

outputs = { self, nixpkgs, crane, treefmt-nix, home-manager, ... }:
outputs =
{
self,
nixpkgs,
crane,
treefmt-nix,
home-manager,
...
}:
let
system = "x86_64-linux";
pkgs = import nixpkgs { inherit system; };

devInputs = with pkgs; [ rustc rustfmt cargo ];
devInputs = with pkgs; [
rustc
rustfmt
cargo
];

nativeBuildInputs = with pkgs; [
makeWrapper
Expand All @@ -42,24 +53,32 @@
craneLib = crane.lib.${system};
fontFilter = path: _type: builtins.match ".*ttf$" path != null;
configFilter = path: _type: builtins.match ".*config.yml$" path != null;
assetOrCargo = path: type:
(configFilter path type) || (fontFilter path type)
|| (craneLib.filterCargoSources path type);
assetOrCargo =
path: type:
(configFilter path type) || (fontFilter path type) || (craneLib.filterCargoSources path type);
commonArgs = {
src = pkgs.lib.cleanSourceWith {
src = craneLib.path ./.;
filter = assetOrCargo;
};
inherit pname version buildInputs nativeBuildInputs;
inherit
pname
version
buildInputs
nativeBuildInputs
;
};
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
cargoClippy = craneLib.cargoClippy (commonArgs // {
inherit cargoArtifacts;
cargoClippyExtraArgs = "--all-targets --all-features";
});
cargoClippy = craneLib.cargoClippy (
commonArgs
// {
inherit cargoArtifacts;
cargoClippyExtraArgs = "--all-targets --all-features";
}
);
GIT_DATE = "${builtins.substring 0 4 self.lastModifiedDate}-${
builtins.substring 4 2 self.lastModifiedDate
}-${builtins.substring 6 2 self.lastModifiedDate}";
builtins.substring 4 2 self.lastModifiedDate
}-${builtins.substring 6 2 self.lastModifiedDate}";
GIT_REV = self.shortRev or "Not committed yet.";
treefmt = (treefmt-nix.lib.evalModule pkgs ./formatter.nix).config.build;
libPath = pkgs.lib.makeLibraryPath [
Expand All @@ -69,68 +88,86 @@
pkgs.libGL
];

in {
in
{
devShells.${system}.default = pkgs.mkShell {
inherit nativeBuildInputs buildInputs GIT_DATE GIT_REV;
inherit
nativeBuildInputs
buildInputs
GIT_DATE
GIT_REV
;
packages = devInputs ++ [ treefmt.wrapper ];
LD_LIBRARY_PATH = libPath;
};
packages.${system} = {
default = craneLib.buildPackage (commonArgs // {
inherit cargoArtifacts nativeBuildInputs buildInputs pname GIT_REV
GIT_DATE;
postFixup = pkgs.lib.optional pkgs.stdenv.isLinux ''
rpath=$(patchelf --print-rpath $out/bin/${pname})
patchelf --set-rpath "$rpath:${libPath}" $out/bin/${pname}
'';
default = craneLib.buildPackage (
commonArgs
// {
inherit
cargoArtifacts
nativeBuildInputs
buildInputs
pname
GIT_REV
GIT_DATE
;
postFixup = pkgs.lib.optional pkgs.stdenv.isLinux ''
rpath=$(patchelf --print-rpath $out/bin/${pname})
patchelf --set-rpath "$rpath:${libPath}" $out/bin/${pname}
'';

meta = with pkgs.lib; {
description = "Your trusty omnibox search.";
homepage = "https://github.com/friedow/centerpiece";
platforms = platforms.linux;
license = licenses.mit;
mainProgram = pname;
maintainers = [ "friedow" ];
};
});
index-git-repositories = craneLib.buildPackage (commonArgs // rec {
inherit cargoArtifacts;
pname = "index-git-repositories";
cargoExtraArgs = "-p ${pname}";
meta.mainProgram = pname;
});
meta = with pkgs.lib; {
description = "Your trusty omnibox search.";
homepage = "https://github.com/friedow/centerpiece";
platforms = platforms.linux;
license = licenses.mit;
mainProgram = pname;
maintainers = [ "friedow" ];
};
}
);
index-git-repositories = craneLib.buildPackage (
commonArgs
// rec {
inherit cargoArtifacts;
pname = "index-git-repositories";
cargoExtraArgs = "-p ${pname}";
meta.mainProgram = pname;
}
);
};
checks.${system} = {
inherit (self.outputs.packages.${system})
default index-git-repositories;
inherit (self.outputs.packages.${system}) default index-git-repositories;
shell = self.outputs.devShells.${system}.default;
treefmt = treefmt.check self;
inherit cargoClippy;
hmModule = (nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
home-manager.nixosModules.home-manager
{
home-manager.users.alice = {
imports = [ self.outputs.hmModules."x86_64-linux".default ];
programs.centerpiece = {
enable = true;
config.plugin.git_repositories.commands = [ [ "alacritty" ] ];
services.index-git-repositories = {
hmModule =
(nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
home-manager.nixosModules.home-manager
{
home-manager.users.alice = {
imports = [ self.outputs.hmModules."x86_64-linux".default ];
programs.centerpiece = {
enable = true;
interval = "3hours";
config.plugin.git_repositories.commands = [ [ "alacritty" ] ];
services.index-git-repositories = {
enable = true;
interval = "3hours";
};
};
home.stateVersion = "23.11";
};
users.users.alice = {
isNormalUser = true;
uid = 1000;
home = "/home/alice";
};
home.stateVersion = "23.11";
};
users.users.alice = {
isNormalUser = true;
uid = 1000;
home = "/home/alice";
};
}
];
}).config.system.build.vm;
}
];
}).config.system.build.vm;
};
hmModules.${system}.default = import ./home-manager-module.nix {
centerpiece = self.outputs.packages.${system}.default;
Expand Down
Loading