Skip to content

Commit

Permalink
Pull ayamir/nvimdots branch main
Browse files Browse the repository at this point in the history
  • Loading branch information
TonyWu20 committed May 27, 2024
2 parents 8f0ff31 + 73af5db commit 0e29f64
Show file tree
Hide file tree
Showing 15 changed files with 499 additions and 193 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/update_flake.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: update flake.lock
on:
# Scheduled update (1st of every month)
schedule: [{ cron: "30 02 1 * *" }]

jobs:
update-lockfile:
if: github.repository_owner == 'ayamir'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Required to count the commits
- uses: cachix/install-nix-action@v26
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: Run flake-update
run: |
nix flake update
- uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "chore(lockfile): auto update flake.lock"
commit_user_name: "github-actions[bot]"
commit_user_email: "41898282+github-actions[bot]@users.noreply.github.com"
commit_author: "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>"
file_pattern: "flake.lock"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
lua/modules/plugins/custom.lua
lua/modules/configs/custom
lua/user
result
7 changes: 7 additions & 0 deletions .nixd.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"formatting": {
"command": [
"nixpkgs-fmt"
]
}
}
154 changes: 154 additions & 0 deletions flake.lock

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

101 changes: 96 additions & 5 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,102 @@
# because "doq" is not included in the stable version.
description = "Provide nixosModules for ayamir/nvimdots";

inputs = { };

outputs = inputs: {
homeManagerModules = {
nvimdots = ./nixos;
inputs = {
flake-parts.url = "github:hercules-ci/flake-parts";
devshell.url = "github:numtide/devshell";
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = inputs @ { self, flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; }
{
imports = [
inputs.devshell.flakeModule
];
flake = {
homeManagerModules = {
nvimdots = ./nixos;
};
};
systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
perSystem = { pkgs, system, ... }: {
packages = {
testEnv = (import ./nixos/testEnv.nix { inherit inputs pkgs; }).activationPackage;
check-linker = pkgs.writeShellApplication {
name = "check-linker";
text =
let
ldd_cmd = if pkgs.stdenv.isDarwin then "otool -L" else "${pkgs.glibc.bin}/bin/ldd";
in
''
#shellcheck disable=SC1090
source <(sed -ne :1 -e 'N;1,1b1' -e 'P;D' "${self.packages.${system}.testEnv}/home-path/bin/nvim")
echo "check file under ''${XDG_DATA_HOME}/''${NVIM_APPNAME:-nvim}/mason/bin"
find "''${XDG_DATA_HOME}/''${NVIM_APPNAME:-nvim}/mason/bin" -type l | while read -r link; do
"${ldd_cmd}" "$(readlink -f "$link")" > /dev/zero 2>&1 || continue
linkers=$("${ldd_cmd}" "$(readlink -f "$link")" | tail -n+2)
echo "$linkers" | while read -r line; do
[ -z "$line" ] && continue
echo "$line" | grep -q "/nix/store" || printf '%s: %s do not link to /nix/store \n' "$(basename "$link")" "$line"
done
done
echo "check done"
'';
};
};
devshells.default = {
commands = [
{
help = "neovim linked to testEnv.";
name = "nvim";
command = ''
${self.packages.${system}.testEnv}/home-path/bin/nvim
'';
}
{
help = "check-linker";
package = self.packages.${system}.check-linker;
}
];
devshell = {
motd = ''
{202}🔨 Welcome to devshell{reset}
Symlink configs to "''${XDG_CONFIG_HOME}"/nvimdots!
And NVIM_APPNAME=nvimdots is already configured, so neovim will put file under "\$XDG_xxx_HOME"/nvimdots.
To uninstall, remove "\$XDG_xxx_HOME"/nvimdots.
$(type -p menu &>/dev/null && menu)
'';
startup = {
mkNvimDir = {
text = ''
mkdir -p "''${XDG_CONFIG_HOME}"/nvimdots
for path in lazy-lock.json init.lua lua snips tutor; do
ln -sf "''${PWD}/''${path}" "''${XDG_CONFIG_HOME}"/nvimdots/
done
'';
};
};
};
env = [
{
name = "NVIM_APPNAME";
value = "nvimdots";
}
{
name = "PATH";
prefix = "${self.packages.${system}.testEnv}/home-path/bin";
}
];
packages = with pkgs; [
nixd
nixpkgs-fmt
];
};
};
};
}
Loading

0 comments on commit 0e29f64

Please sign in to comment.