Skip to content

Commit

Permalink
Merge pull request #805 from kachick/replace-nil-with-nixd
Browse files Browse the repository at this point in the history
Refine use of nixd
  • Loading branch information
kachick authored Sep 27, 2024
2 parents 9439008 + 87babdc commit 65ff559
Show file tree
Hide file tree
Showing 20 changed files with 216 additions and 190 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ insert_final_newline = true
[*.md]
trim_trailing_whitespace = false

[{Makefile,*.mk,*.go,.gitmodules,*.*sh,.*shrc,*shenv,.bash_*}]
[{Makefile,*.mk,*.go,.gitmodules,*.*sh,.*shrc,*shenv,.bash_*,*.envrc}]
indent_style = tab
indent_size = 4

Expand Down
4 changes: 0 additions & 4 deletions .envrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
#!/usr/bin/env -S bash

use flake

# To avoid absolute path for Nix and typos-lsp in vscode settings
TYPOS_LSP_PATH="$(command -v typos-lsp)"
export TYPOS_LSP_PATH
1 change: 0 additions & 1 deletion .github/workflows/ci-nix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ on:

jobs:
tasks:
if: (github.event_name != 'pull_request') || (!github.event.pull_request.draft)
strategy:
fail-fast: false
matrix:
Expand Down
7 changes: 1 addition & 6 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,8 @@
"[lua]": {
"editor.defaultFormatter": "JohnnyMorganz.stylua"
},
"nix.serverPath": "nil",
"nix.serverPath": "nixd",
"nix.enableLanguageServer": true,
"nix.serverSettings": {
"nil": {
"formatting": { "command": ["nixfmt"] }
}
},
"gopls": {
"build.buildFlags": ["-tags=linux,windows,darwin"]
},
Expand Down
3 changes: 3 additions & 0 deletions .zed/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
"command": "nixfmt",
"arguments": ["-"]
}
},
"inlay_hints": {
"enabled": true
}
},
"Go": {
Expand Down
1 change: 1 addition & 0 deletions cmd/lint/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ func main() {

if *allFlag {
cmds = append(cmds, runner.Cmd{Path: "trivy", Args: []string{"config", "--exit-code", "1", "."}})
cmds = append(cmds, runner.Cmd{Path: "nix", Args: []string{"run", ".#check_nixf"}})
}

cmds.ParallelRun()
Expand Down
14 changes: 8 additions & 6 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
nixpkgs,
edge-nixpkgs,
home-manager,
nixos-wsl,
xremap-flake,
...
}@inputs:
let
inherit (self) outputs;
Expand Down Expand Up @@ -65,14 +64,16 @@
in
{
default = pkgs.mkShellNoCC {
# Realize nixd pkgs version inlay hints for stable channel instead of latest
NIX_PATH = "nixpkgs=${pkgs.path}";

TYPOS_LSP_PATH = pkgs.lib.getExe pkgs.typos-lsp;

buildInputs =
(with pkgs; [
# https://github.com/NixOS/nix/issues/730#issuecomment-162323824
bashInteractive
nixfmt-rfc-style
# TODO: Consider to replace nil with nixd: https://github.com/oxalica/nil/issues/111
nil # Used in vscode Nix extension
nixd # Used in zed Nix extension
nixpkgs-lint-community
nix-init
nurl
Expand All @@ -85,12 +86,12 @@
dprint
stylua
typos
typos-lsp
go_1_22
goreleaser
trivy
])
++ (with edge-pkgs; [
nixd
# Don't use treefmt(treefmt1) that does not have crucial feature to cover hidden files
# https://github.com/numtide/treefmt/pull/250
treefmt2
Expand All @@ -117,6 +118,7 @@
"bump_completions"
"bump_gomod"
"check_no_dirty_xz_in_nix_store"
"check_nixf"
"bench_shells"
"walk"
"ir"
Expand Down
3 changes: 0 additions & 3 deletions home-manager/common.nix
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@
enableNixpkgsReleaseCheck = true;

sessionVariables = {
# Do NOT set GIT_EDITOR, it overrides `core.editor` in git config
# https://unix.stackexchange.com/questions/4859/visual-vs-editor-what-s-the-difference
EDITOR = lib.getExe pkgs.helix;
PAGER = "less";

# https://github.com/sharkdp/bat/blob/v0.24.0/README.md?plain=1#L201-L219
Expand Down
30 changes: 19 additions & 11 deletions home-manager/editors.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ pkgs, ... }:
{ pkgs, lib, ... }:

{
# Don't add unfree packages like vscode here for using in containers
Expand All @@ -12,14 +12,22 @@
# TODO: Update since merged https://github.com/nix-community/home-manager/pull/5455
xdg.configFile."zed/settings.json".source = ../config/zed/settings.json;

# Should have `root = true` in the file. - https://github.com/kachick/anylang-template/blob/45d7ef685ac4fd3836c3b32b8ce8fb45e909b771/.editorconfig#L1
# Intentionally avoided to use https://github.com/nix-community/home-manager/blob/f58889c07efa8e1328fdf93dc1796ec2a5c47f38/modules/misc/editorconfig.nix
home.file.".editorconfig".source =
pkgs.fetchFromGitHub {
owner = "kachick";
repo = "anylang-template";
rev = "45d7ef685ac4fd3836c3b32b8ce8fb45e909b771";
sha256 = "sha256-F8xP4xCIS1ybvRm1xGB2USekGWKKxz0nokpY6gRxKBE=";
}
+ "/.editorconfig";
home = {
sessionVariables = {
# Do NOT set GIT_EDITOR, it overrides `core.editor` in git config
# https://unix.stackexchange.com/questions/4859/visual-vs-editor-what-s-the-difference
EDITOR = lib.getExe pkgs.helix;
};

# Should have `root = true` in the file. - https://github.com/kachick/anylang-template/blob/45d7ef685ac4fd3836c3b32b8ce8fb45e909b771/.editorconfig#L1
# Intentionally avoided to use https://github.com/nix-community/home-manager/blob/f58889c07efa8e1328fdf93dc1796ec2a5c47f38/modules/misc/editorconfig.nix
file.".editorconfig".source =
pkgs.fetchFromGitHub {
owner = "kachick";
repo = "anylang-template";
rev = "45d7ef685ac4fd3836c3b32b8ce8fb45e909b771";
sha256 = "sha256-F8xP4xCIS1ybvRm1xGB2USekGWKKxz0nokpY6gRxKBE=";
}
+ "/.editorconfig";
};
}
2 changes: 1 addition & 1 deletion home-manager/fish.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ lib, pkgs, ... }:
{ pkgs, ... }:

{
services.gpg-agent.enableFishIntegration = true;
Expand Down
1 change: 0 additions & 1 deletion home-manager/git.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
pkgs,
homemade-pkgs,
lib,
config,
...
}:

Expand Down
8 changes: 1 addition & 7 deletions home-manager/gnome.nix
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
{
config,
lib,
pkgs,
edge-pkgs,
...
}:
{ lib, pkgs, ... }:

let
spotify-pwa-file = "chrome-pjibgclleladliembfgfagdaldikeohf-Default.desktop";
Expand Down
Loading

0 comments on commit 65ff559

Please sign in to comment.