Compare commits

..

7 Commits

13 changed files with 210 additions and 107 deletions

View File

@ -117,11 +117,11 @@
"utils": "utils"
},
"locked": {
"lastModified": 1673737886,
"narHash": "sha256-hNTqD0uIgpbtTI2Nuj/Q1lEFOOdZqqXpxoc8rMno2F0=",
"lastModified": 1673948101,
"narHash": "sha256-cD0OzFfnLFeeaz4jVszH9QiMTn+PBxmcYzrp+xujpwM=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "2827b5306462d91edec16a3d069b2d6e54c3079f",
"rev": "bd3efacb82c721edad1ce9eda583df5fb62ab00a",
"type": "github"
},
"original": {
@ -156,11 +156,11 @@
},
"locked": {
"dir": "contrib",
"lastModified": 1673746461,
"narHash": "sha256-Y21pbVNlPWPokXFbngSahnxeCff0LX+LKdDktEBIVm4=",
"lastModified": 1673937267,
"narHash": "sha256-zixnItZtMZRKK0bEh8UOBeh8JT4jeMzPR2TtacfXmyE=",
"owner": "neovim",
"repo": "neovim",
"rev": "6134c1e8a39a5e61d0593613343a5923a86e3545",
"rev": "2093e574c6c934a718f96d0a173aa965d3958a8b",
"type": "github"
},
"original": {
@ -177,11 +177,11 @@
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1673770422,
"narHash": "sha256-hYVEUzvqobxAM2FZfWTrTLKKNfkOSfsm0uGqNoSiIvw=",
"lastModified": 1673943288,
"narHash": "sha256-TDo9wDfZH+MJ/tTeCtZ67jdHqtVvIxetLpFN9+vqZ7g=",
"owner": "nix-community",
"repo": "neovim-nightly-overlay",
"rev": "fd8e5953cfeada345d7daeedce6ab0919f1284d4",
"rev": "3c0bb335936754a2683a84ddf081594ddb567a89",
"type": "github"
},
"original": {
@ -226,6 +226,21 @@
"type": "path"
}
},
"nixlib": {
"locked": {
"lastModified": 1673743903,
"narHash": "sha256-sloY6KYyVOozJ1CkbgJPpZ99TKIjIvM+04V48C04sMQ=",
"owner": "nix-community",
"repo": "nixpkgs.lib",
"rev": "7555e2dfcbac1533f047021f1744ac8871150f9f",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixpkgs.lib",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1671983799,
@ -298,6 +313,7 @@
"neovim-nightly-overlay": "neovim-nightly-overlay",
"nix-index-database": "nix-index-database",
"nixgl": "nixgl",
"nixlib": "nixlib",
"nixpkgs": "nixpkgs_3",
"rust-overlay": "rust-overlay"
}
@ -308,11 +324,11 @@
"nixpkgs": "nixpkgs_4"
},
"locked": {
"lastModified": 1673749717,
"narHash": "sha256-hgrw8w/AThRWfVafx3EO3/TQlGcUou4nui8X47cVhXo=",
"lastModified": 1673922364,
"narHash": "sha256-U0XIY/Y/x4fFtlCZKMtWlqOYUnLiXj4F42GQHxWuPow=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "aab6eb2dfc7a1e42d94b6f24ef13639ff8544af4",
"rev": "4e0f9b8a5102387f8d19901bced16a256a6ccdc7",
"type": "github"
},
"original": {

View File

@ -1,10 +1,15 @@
{
nixConfig = {
accept-flake-config = true;
experimental-features = "nix-command flakes";
# for darwin's browser
allowUnsupportedSystem = true;
};
description = "My personal configuration in Nix (and some native configurations)";
inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable";
# continously merged & rebased lightweight .lib. Basically a huge extension to c_.
nixlib.url = "github:nix-community/nixpkgs.lib";
agenix = {
url = "github:ryantm/agenix";
inputs.nixpkgs.follows = "nixpkgs";
@ -45,8 +50,50 @@
, flake-compat
, neovim-nightly-overlay
, nix-index-database
, nixlib
, ...
}@_inputs:
let
# config_fn:: system -> config
# this function should take simple exports of homeConfigurations.${profile},
# nixosConfigurations.${profile}, devShells.${profile}, packages.${profile}
# and correctly produce
cross_platform = config_fn: let
# nixosConfigurations.${profile} -> nixosConfigurations.${system}.${profile}
# pass in: path.to.exports.nixosConfigurations
# get out: nixosConfigurations.${system} = {...}
strat_sandwich = field_name: config_field: system: {
"${field_name}"."${system}" = config_field;
};
# homeConfigurations.${profile} -> packages.${system}.homeConfigurations.${profile}
# pass in: path.to.exports.homeConfigurations
# get: packages.${system}.homeConfigurations
strat_wrap_packages = field_name: config_field: system: {
packages."${system}"."${field_name}" = config_field;
};
strat_noop = field_name: config_field: system: {"${field_name}" = config_field;};
strategyMap = {
nixosConfigurations = strat_sandwich;
templates = strat_noop;
devShells = strat_sandwich;
devShell = strat_sandwich;
formatter = strat_sandwich;
homeConfigurations = strat_wrap_packages;
lib = strat_noop;
proj_root = strat_noop;
unit_tests = strat_noop;
secrets = strat_noop;
debug = strat_noop;
};
# takes in {homeConfigurations = ...; nixosConfigurations = ...}
# -> {packages.$system.homeConfigurations}
mapConfig = config: system: (builtins.foldl'
(acc: confName: (strategyMap."${confName}" confName config."${confName}" system))
{} (builtins.attrNames config));
in builtins.foldl' nixlib.lib.recursiveUpdate {} (
builtins.map (system: (mapConfig (config_fn system) system)) flake-utils.lib.defaultSystems
);
in cross_platform (system:
let
# Context/global stuffs to be passed down
# NOTE: this will only read files that are within git tree
@ -65,17 +112,9 @@
hosts.path = "${path}/hosts";
users.path = "${path}/users";
};
# TODO: adapt to different platforms think about different systems later
system = "x86_64-linux";
overlays = [
rust-overlay.overlays.default
(self: pkgs@{ lib, ... }: {
lib = pkgs.lib // (import ./lib (_inputs // { inherit pkgs proj_root; }));
})
];
overlays = import ./overlays.nix (_inputs // {inherit system;});
pkgs = import nixpkgs {
inherit system;
overlays = import ./overlays.nix _inputs;
inherit system overlays;
config = {
allowUnfree = true;
};
@ -121,7 +160,7 @@
inherit (hosts) nixosConfigurations;
inherit (users) homeConfigurations;
inherit lib proj_root;
devShell."${system}" = import ./dev-shell.nix final_inputs;
devShells = import ./dev-shell.nix final_inputs;
templates = import ./templates final_inputs;
secrets = {
pubKeys = {
@ -130,10 +169,10 @@
};
};
unit_tests = lib.runTests unit_tests;
# unit_tests = lib.runTests unit_tests;
debug = {
inherit final_inputs hosts users modules lib inputs_w_lib unit_tests pkgs nixpkgs;
inherit final_inputs hosts users modules lib inputs_w_lib unit_tests pkgs nixpkgs nixlib;
};
formatter."${system}" = pkgs.nixpkgs-fmt;
};
});
}

View File

@ -34,25 +34,6 @@
in
"${mount_dest} ${confToBackendArg backend_args} :${s3fs-exec}\#${bucket}";
personalStorage = [
# hungtr-hot @ phoenix is broken :)
# (autofs-s3fs_entry {
# mount_dest = "hot";
# backend_args = {
# "-fstype" = "fuse";
# use_cache = "/tmp";
# del_cache = null;
# allow_other = null;
# url = ''"https://f5i0.ph.idrivee2-32.com"'';
# # TODO: builtins.readFile requires a Git-controlled file
# passwd_file = config.age.secrets.s3fs.path;
# dbglevel = "debug"; # enable this for better debugging info in journalctl
# uid = "1000"; # default user
# gid = "100"; # users
# umask="003"; # others read only, fully shared for users group
# # _netdev = null; # ignored by s3fs (https://github.com/s3fs-fuse/s3fs-fuse/blob/master/src/s3fs.cpp#L4910)
# };
# bucket = "hungtr-hot";
# })
(autofs-s3fs_entry {
mount_dest = "garden";
backend_args = {

View File

@ -607,7 +607,7 @@ local capabilities = require('cmp_nvim_lsp').default_capabilities()
-- default language servers
local servers = {
'clangd', 'rust_analyzer', 'pyright', 'tsserver', 'sumneko_lua', 'cmake', 'tailwindcss', 'prismals',
'rnix', 'eslint', 'terraformls', 'tflint', 'svelte', 'astro', 'clojure_lsp', "bashls", 'yamlls', "pylsp",
'rnix', 'eslint', 'terraformls', 'tflint', 'svelte', 'astro', 'clojure_lsp', "bashls", 'yamlls',
"jsonls", "denols"
}
require("mason").setup({

View File

@ -1,5 +1,6 @@
# TODO: vim-plug and Mason supports laziness. Probably worth it to explore
# incremental dependencies based on the project
# TODO: just install these things, then symlink to mason's bin directory
#
# One thing to consider, though, /nix/store of `nix-shell` or `nix-develop`
# might be different from `home-manager`'s
@ -44,23 +45,22 @@ let
pkgs.zk # Zettelkasten (limited support)
pkgs.fd # Required by a Telescope plugin (?)
pkgs.stdenv.cc.cc.lib
pkgs.rnix-lsp # doesn't work, Mason just installs it using cargo
pkgs.rust4cargo
# Language-specific stuffs
pkgs.sumneko-lua-language-server
# pkgs.python3Packages.python-lsp-server
pkgs.nodePackages.pyright
pkgs.python3Packages.pylint
pkgs.python3Packages.flake8
# TODO: the devShell should provide rust-analyzer so that
# cargo test builds binaries compatible with rust-analyzer
# pkgs.rust-analyzer
# rust_pkgs
# pkgs.evcxr # Rust REPL for Conjure!
# Python3 as alternative to bash scripts :^)
# (pkgs.python310Full.withPackages (pypkgs: [
# # python-lsp-server's dependencies is absolutely astronomous
# # pypkgs.python-lsp-server # python-lsp. Now we'll have to tell mason to look for this
# pypkgs.pynvim # nvim provider
# pypkgs.ujson # pylsp seems to rely on this. satisfy it lol
# ]))
];
in
{

View File

@ -1,12 +1,11 @@
# We use top-level nix-flake, so default.nix is basically just a wrapper around ./flake.nix
(import
(
# Get corresponding version of flake-compat declared in on ./flake.lock
let lock = builtins.fromJSON (builtins.readFile ./flake.lock); in
fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
c_ = import ./../../c_.nix {src = ./.;};
in
c_.fetchTree lock.nodes.flake-compat.locked
)
{ src = ./.; } # calls flake.nix
{ src = ./.; }
).defaultNix

View File

@ -97,11 +97,11 @@
"utils": "utils"
},
"locked": {
"lastModified": 1673737886,
"narHash": "sha256-hNTqD0uIgpbtTI2Nuj/Q1lEFOOdZqqXpxoc8rMno2F0=",
"lastModified": 1673948101,
"narHash": "sha256-cD0OzFfnLFeeaz4jVszH9QiMTn+PBxmcYzrp+xujpwM=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "2827b5306462d91edec16a3d069b2d6e54c3079f",
"rev": "bd3efacb82c721edad1ce9eda583df5fb62ab00a",
"type": "github"
},
"original": {
@ -136,11 +136,11 @@
},
"locked": {
"dir": "contrib",
"lastModified": 1673746461,
"narHash": "sha256-Y21pbVNlPWPokXFbngSahnxeCff0LX+LKdDktEBIVm4=",
"lastModified": 1673937267,
"narHash": "sha256-zixnItZtMZRKK0bEh8UOBeh8JT4jeMzPR2TtacfXmyE=",
"owner": "neovim",
"repo": "neovim",
"rev": "6134c1e8a39a5e61d0593613343a5923a86e3545",
"rev": "2093e574c6c934a718f96d0a173aa965d3958a8b",
"type": "github"
},
"original": {
@ -157,11 +157,11 @@
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1673770422,
"narHash": "sha256-hYVEUzvqobxAM2FZfWTrTLKKNfkOSfsm0uGqNoSiIvw=",
"lastModified": 1673943288,
"narHash": "sha256-TDo9wDfZH+MJ/tTeCtZ67jdHqtVvIxetLpFN9+vqZ7g=",
"owner": "nix-community",
"repo": "neovim-nightly-overlay",
"rev": "fd8e5953cfeada345d7daeedce6ab0919f1284d4",
"rev": "3c0bb335936754a2683a84ddf081594ddb567a89",
"type": "github"
},
"original": {
@ -239,11 +239,11 @@
},
"nixpkgs_3": {
"locked": {
"lastModified": 1673631141,
"narHash": "sha256-AprpYQ5JvLS4wQG/ghm2UriZ9QZXvAwh1HlgA/6ZEVQ=",
"lastModified": 1673796341,
"narHash": "sha256-1kZi9OkukpNmOaPY7S5/+SlCDOuYnP3HkXHvNDyLQcc=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "befc83905c965adfd33e5cae49acb0351f6e0404",
"rev": "6dccdc458512abce8d19f74195bb20fdb067df50",
"type": "github"
},
"original": {
@ -288,11 +288,11 @@
"nixpkgs": "nixpkgs_4"
},
"locked": {
"lastModified": 1673749717,
"narHash": "sha256-hgrw8w/AThRWfVafx3EO3/TQlGcUou4nui8X47cVhXo=",
"lastModified": 1673922364,
"narHash": "sha256-U0XIY/Y/x4fFtlCZKMtWlqOYUnLiXj4F42GQHxWuPow=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "aab6eb2dfc7a1e42d94b6f24ef13639ff8544af4",
"rev": "4e0f9b8a5102387f8d19901bced16a256a6ccdc7",
"type": "github"
},
"original": {

View File

@ -2,6 +2,14 @@
nixConfig = {
accept-flake-config = true;
experimental-features = "nix-command flakes";
extra-substituters = [
"https://nix-community.cachix.org"
"https://cache.nixos.org"
];
extra-trusted-public-keys = [
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
];
};
description = "simple home-manager config";
inputs = {
@ -56,7 +64,7 @@
in
cross_platform (system:
let
overlays = import ./../../overlays.nix flake_inputs;
overlays = import ./../../overlays.nix (flake_inputs // {inherit system;});
# pkgs = nixpkgs.legacyPackages.${system}.appendOverlays overlays;
pkgs = import nixpkgs {
inherit system overlays;
@ -131,6 +139,7 @@
};
};
};
# Personal darwin, effectively serves as the Darwin edge channel
"hungtran" = home-manager.lib.homeManagerConfiguration {
inherit pkgs;
modules = base.modules ++ [
@ -140,10 +149,14 @@
# don't want to deal with GL stuffs on mac yet :/
base.graphics.useNixGL.defaultPackage = null;
# NOTE: this actually does not exist
base.keepass.path = "/Users/htran/keepass.kdbx";
base.keepass.path = "/Users/hungtran/keepass.kdbx";
base.alacritty.font.size = 11.0;
}
nerd_font_module
./base/productive_desktop.nix
{
base.private_chromium.enable = false;
}
];
extraSpecialArgs = mkModuleArgs {
inherit pkgs;
@ -153,6 +166,7 @@
};
};
};
# Work darwin
"htran" = home-manager.lib.homeManagerConfiguration {
inherit pkgs;
modules = base.modules ++ [
@ -164,6 +178,8 @@
# NOTE: this actually does not exist
base.keepass.path = "/Users/htran/keepass.kdbx";
base.alacritty.font.size = 11.0;
base.git.name = "Hung";
base.git.email = "htran@egihosting.com";
}
nerd_font_module
];

View File

@ -1,13 +1,27 @@
flake_input@{ kpcli-py, nixgl, rust-overlay, neovim-nightly-overlay, ... }: [
flake_input@{ kpcli-py
, nixgl
, rust-overlay
, neovim-nightly-overlay
, system
, ...
}: let
kpcli-py = (final: prev: {
# use python3.9, which works because of cython somehow?
kpcli-py = final.poetry2nix.mkPoetryApplication {
projectDir = flake_input.kpcli-py;
python = final.python39;
overrides = final.poetry2nix.defaultPoetryOverrides.extend (self: super: {
# tableformatter requires setuptools
tableformatter = super.tableformatter.overridePythonAttrs (
old: {
buildInputs = (old.buildInputs or [ ]) ++ [ super.setuptools super.cython_3 ];
}
);
});
};
});
# TODO: this is quite harmful to add globally. nixGL is built not to be pure
nixgl.overlays.default
rust-overlay.overlays.default
neovim-nightly-overlay.overlay
(final: prev:
rust = (final: prev:
let
nightlyRustWithExts = exts: final.rust-bin.selectLatestNightlyWith (
toolchain: (toolchain.minimal.override {
@ -17,26 +31,16 @@ flake_input@{ kpcli-py, nixgl, rust-overlay, neovim-nightly-overlay, ... }: [
# https://rust-lang.github.io/rustup/concepts/profiles.html
rust-default-components = [ "rust-docs" "rustfmt" "clippy" ];
rust-dev-components = rust-default-components ++ [ "rust-src" "rust-analyzer" "miri" ];
in
{
# use python3.9, which works because of cython somehow?
kpcli-py = final.poetry2nix.mkPoetryApplication {
projectDir = kpcli-py;
python = final.python39;
overrides = final.poetry2nix.defaultPoetryOverrides.extend (self: super: {
# tableformatter requires setuptools
tableformatter = super.tableformatter.overridePythonAttrs (
old: {
buildInputs = (old.buildInputs or [ ]) ++ [ super.setuptools super.cython_3 ];
}
);
});
};
in {
rust4devs = nightlyRustWithExts rust-dev-components;
rust4cargo = nightlyRustWithExts [ ];
rust4normi = nightlyRustWithExts rust-default-components;
})
});
in [
nixgl.overlays.default
rust-overlay.overlays.default
neovim-nightly-overlay.overlay
rust
kpcli-py
]

View File

@ -16,4 +16,8 @@
path = ./ts/turborepo;
description = "Typescript monorepo with tsconfig, eslint, but with minimal framework attached";
};
py-poetry = {
path = ./py-poetry;
description = "Python repository with poetry & poetry2nix";
};
}

View File

@ -0,0 +1,10 @@
(import
(
fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/99f1c2157fba4bfe6211a321fd0ee43199025dbf.tar.gz";
sha256 = "0x2jn3vrawwv9xp15674wjz9pixwjyj3j771izayl962zziivbx2";
}
)
{
src = ./.;
}).defaultNix

View File

@ -0,0 +1,24 @@
{
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
outputs = { self, nixpkgs }:
let
supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
pkgs = forAllSystems (system: nixpkgs.legacyPackages.${system});
in
{
packages = forAllSystems (system: {
default = pkgs.${system}.poetry2nix.mkPoetryApplication { projectDir = self; };
});
devShells = forAllSystems (system: {
default = pkgs.${system}.mkShellNoCC {
packages = with pkgs.${system}; [
(poetry2nix.mkPoetryEnv { projectDir = self; })
poetry
];
};
});
};
}

View File

@ -0,0 +1,10 @@
(import
(
fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/99f1c2157fba4bfe6211a321fd0ee43199025dbf.tar.gz";
sha256 = "0x2jn3vrawwv9xp15674wjz9pixwjyj3j771izayl962zziivbx2";
}
)
{
src = ./.;
}).shellNix