Compare commits

..

No commits in common. "295166292a4b462dbf805e68d9793ae2b67aef5e" and "d4f6cf27a9e297238e4b56c702a73a30a1f246ba" have entirely different histories.

7 changed files with 98 additions and 143 deletions

View File

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

View File

@ -1,15 +1,10 @@
{ {
nixConfig = { 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)"; description = "My personal configuration in Nix (and some native configurations)";
inputs = { inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable"; nixpkgs.url = "nixpkgs/nixos-unstable";
# continously merged & rebased lightweight .lib. Basically a huge extension to c_.
nixlib.url = "github:nix-community/nixpkgs.lib";
agenix = { agenix = {
url = "github:ryantm/agenix"; url = "github:ryantm/agenix";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
@ -50,50 +45,8 @@
, flake-compat , flake-compat
, neovim-nightly-overlay , neovim-nightly-overlay
, nix-index-database , nix-index-database
, nixlib
, ... , ...
}@_inputs: }@_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 let
# Context/global stuffs to be passed down # Context/global stuffs to be passed down
# NOTE: this will only read files that are within git tree # NOTE: this will only read files that are within git tree
@ -112,9 +65,17 @@
hosts.path = "${path}/hosts"; hosts.path = "${path}/hosts";
users.path = "${path}/users"; 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; }));
})
];
pkgs = import nixpkgs { pkgs = import nixpkgs {
inherit system; inherit system;
overlays = import ./overlays.nix (_inputs // {inherit system;}); overlays = import ./overlays.nix _inputs;
config = { config = {
allowUnfree = true; allowUnfree = true;
}; };
@ -125,7 +86,7 @@
nixpkgs.lib nixpkgs.lib
pkgs.lib pkgs.lib
(import ./lib { (import ./lib {
inherit proj_root pkgs system; inherit proj_root pkgs overlays system;
inherit (pkgs) lib; inherit (pkgs) lib;
}) })
]); ]);
@ -160,7 +121,7 @@
inherit (hosts) nixosConfigurations; inherit (hosts) nixosConfigurations;
inherit (users) homeConfigurations; inherit (users) homeConfigurations;
inherit lib proj_root; inherit lib proj_root;
devShells = import ./dev-shell.nix final_inputs; devShell."${system}" = import ./dev-shell.nix final_inputs;
templates = import ./templates final_inputs; templates = import ./templates final_inputs;
secrets = { secrets = {
pubKeys = { pubKeys = {
@ -169,10 +130,10 @@
}; };
}; };
# unit_tests = lib.runTests unit_tests; unit_tests = lib.runTests unit_tests;
debug = { debug = {
inherit final_inputs hosts users modules lib inputs_w_lib unit_tests pkgs nixpkgs nixlib; inherit final_inputs hosts users modules lib inputs_w_lib unit_tests pkgs nixpkgs;
}; };
formatter."${system}" = pkgs.nixpkgs-fmt; formatter."${system}" = pkgs.nixpkgs-fmt;
}); };
} }

View File

@ -34,6 +34,25 @@
in in
"${mount_dest} ${confToBackendArg backend_args} :${s3fs-exec}\#${bucket}"; "${mount_dest} ${confToBackendArg backend_args} :${s3fs-exec}\#${bucket}";
personalStorage = [ 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 { (autofs-s3fs_entry {
mount_dest = "garden"; mount_dest = "garden";
backend_args = { backend_args = {

View File

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

View File

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

View File

@ -56,7 +56,7 @@
in in
cross_platform (system: cross_platform (system:
let let
overlays = import ./../../overlays.nix (flake_inputs // {inherit system;}); overlays = import ./../../overlays.nix flake_inputs;
# pkgs = nixpkgs.legacyPackages.${system}.appendOverlays overlays; # pkgs = nixpkgs.legacyPackages.${system}.appendOverlays overlays;
pkgs = import nixpkgs { pkgs = import nixpkgs {
inherit system overlays; inherit system overlays;
@ -131,7 +131,6 @@
}; };
}; };
}; };
# Personal darwin, effectively serves as the Darwin edge channel
"hungtran" = home-manager.lib.homeManagerConfiguration { "hungtran" = home-manager.lib.homeManagerConfiguration {
inherit pkgs; inherit pkgs;
modules = base.modules ++ [ modules = base.modules ++ [
@ -141,14 +140,10 @@
# don't want to deal with GL stuffs on mac yet :/ # don't want to deal with GL stuffs on mac yet :/
base.graphics.useNixGL.defaultPackage = null; base.graphics.useNixGL.defaultPackage = null;
# NOTE: this actually does not exist # NOTE: this actually does not exist
base.keepass.path = "/Users/hungtran/keepass.kdbx"; base.keepass.path = "/Users/htran/keepass.kdbx";
base.alacritty.font.size = 11.0; base.alacritty.font.size = 11.0;
} }
nerd_font_module nerd_font_module
./base/productive_desktop.nix
{
base.private_chromium.enable = false;
}
]; ];
extraSpecialArgs = mkModuleArgs { extraSpecialArgs = mkModuleArgs {
inherit pkgs; inherit pkgs;
@ -158,7 +153,6 @@
}; };
}; };
}; };
# Work darwin
"htran" = home-manager.lib.homeManagerConfiguration { "htran" = home-manager.lib.homeManagerConfiguration {
inherit pkgs; inherit pkgs;
modules = base.modules ++ [ modules = base.modules ++ [

View File

@ -1,27 +1,13 @@
flake_input@{ kpcli-py flake_input@{ kpcli-py, nixgl, rust-overlay, neovim-nightly-overlay, ... }: [
, 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 ];
}
);
});
};
});
rust = (final: prev: # 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:
let let
nightlyRustWithExts = exts: final.rust-bin.selectLatestNightlyWith ( nightlyRustWithExts = exts: final.rust-bin.selectLatestNightlyWith (
toolchain: (toolchain.minimal.override { toolchain: (toolchain.minimal.override {
@ -31,16 +17,26 @@ flake_input@{ kpcli-py
# https://rust-lang.github.io/rustup/concepts/profiles.html # https://rust-lang.github.io/rustup/concepts/profiles.html
rust-default-components = [ "rust-docs" "rustfmt" "clippy" ]; rust-default-components = [ "rust-docs" "rustfmt" "clippy" ];
rust-dev-components = rust-default-components ++ [ "rust-src" "rust-analyzer" "miri" ]; rust-dev-components = rust-default-components ++ [ "rust-src" "rust-analyzer" "miri" ];
in { 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 ];
}
);
});
};
rust4devs = nightlyRustWithExts rust-dev-components; rust4devs = nightlyRustWithExts rust-dev-components;
rust4cargo = nightlyRustWithExts [ ]; rust4cargo = nightlyRustWithExts [ ];
rust4normi = nightlyRustWithExts rust-default-components; rust4normi = nightlyRustWithExts rust-default-components;
}); })
in [
nixgl.overlays.default
rust-overlay.overlays.default
neovim-nightly-overlay.overlay
rust
kpcli-py
] ]