Skip to content

Commit

Permalink
Optimize NixOS-WSL
Browse files Browse the repository at this point in the history
  • Loading branch information
573 committed Nov 11, 2024
1 parent 6a97c37 commit 67882a5
Show file tree
Hide file tree
Showing 15 changed files with 706 additions and 768 deletions.
17 changes: 17 additions & 0 deletions flake.lock

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

140 changes: 49 additions & 91 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
nixos-2211-small.url = "github:NixOS/nixpkgs/nixos-22.11-small";
nixos-2311.url = "github:NixOS/nixpkgs/nixos-23.11";

deploy-rs = {
deploy-rs = {
url = "github:serokell/deploy-rs";
inputs = {
flake-compat.follows = "flake-compat";
Expand Down Expand Up @@ -435,11 +435,10 @@ deploy-rs = {
};

outputs =
{
self,
nixpkgs,
nix-formatter-pack,
...
{ self
, nixpkgs
, nix-formatter-pack
, ...
}@inputs:
let
rootPath = self;
Expand Down Expand Up @@ -484,7 +483,7 @@ deploy-rs = {
{
inherit
inputs
rootPath # specialArgs
rootPath# specialArgs
forEachSystem
;
#inherit (nixpkgs.pkgs.stdenv.hostPlatform) system;
Expand Down Expand Up @@ -564,24 +563,28 @@ deploy-rs = {
});
in
{
/* deploy.nodes.sams9 = {
/* deploy.nodes.sams9 = {
hostname = "localhost";
profiles.system = {
user = "nix-on-droid";
sshUser = "nix-on-droid";
sshUser = "nix-on-droid";
path = inputs.deploy-rs.lib.x86_64-linux.activate.custom inputs.latest.legacyPackages.aarch64-linux.hello "./bin/hello";
};
}; */

# nix shell nixpkgs#deploy-rs --command deploy -s .#sams9 -- --impure
deploy.nodes = listToAttrs [
(mkDeploy "aarch64-linux" "sams9__aarch64-linux")
(mkDeploy "aarch64-linux" "sams9__x86_64-linux")
];
deploy = {
autoRollback = false;
magicRollback = true;
nodes = listToAttrs [
(mkDeploy "aarch64-linux" "sams9__aarch64-linux")
(mkDeploy "aarch64-linux" "sams9__x86_64-linux")
];
};

homeConfigurations = listToAttrs [
/**
calls `mkHome` as defined in ./flake/default.nix (`[system]` and `[name]` parameters) and ./flake/builders/mkHome.nix, latter the place where `extraSpecialArgs` would also go
calls `mkHome` as defined in ./flake/default.nix (`[system]` and `[name]` parameters) and ./flake/builders/mkHome.nix, latter the place where `extraSpecialArgs` would also go
*/
(mkHome "aarch64-linux" "u0_a210@localhost")
(mkHome "x86_64-linux" "dani@maiziedemacchiato")
Expand Down Expand Up @@ -653,78 +656,33 @@ deploy-rs = {
}
)

(mkApp system "nvim" rec {
file = builtins.toFile "file" ''
source @bashLib@
nvim
'';
path =
pkgs:
with pkgs;
(map (x: "${x.custom.programs.neovim.lightweight.outPath}") (
(
let
inherit (pkgs.stdenv) isLinux isx86_64;
in
lib.optionals (isLinux && isx86_64) [
self.nixosConfigurations.DANIELKNB1.config.home-manager.users.nixos
self.homeConfigurations."dani@maiziedemacchiato".config
]
)
++ (
let
inherit (pkgs.stdenv) isLinux isAarch64;
in
lib.optionals (isLinux && isAarch64) [
self.nixOnDroidConfigurations.sams9.config.home-manager.config
]
)
));
})

({
name = "nixvim";
value =
let
pkgs = inputs.nixpkgs.legacyPackages.${system};
in
{
program = builtins.toString (
pkgs.writeShellScript "testnixvim" ''
${self.inputs.nixvim.packages."${system}".default}/bin/nvim
''
);
type = "app";
};
})

(mkApp system "emacs" rec {
(mkApp system "emacs" {
file = builtins.toFile "file" ''
source @bashLib@
emacs
'';
path =
pkgs:
with pkgs;
(map (x: "${x.custom.programs.emacs.finalPackage.outPath}") (
(
let
inherit (pkgs.stdenv) isLinux isx86_64;
in
lib.optionals (isLinux && isx86_64) [
self.nixosConfigurations.DANIELKNB1.config.home-manager.users.nixos
self.homeConfigurations."dani@maiziedemacchiato".config
]
)
++ (
let
inherit (pkgs.stdenv) isLinux isAarch64;
in
lib.optionals (isLinux && isAarch64) [
self.nixOnDroidConfigurations.sams9.config.home-manager.config
]
)
));
with pkgs;
(map (x: "${x.custom.programs.emacs-no-el.finalPackage.outPath}") (
(
let
inherit (pkgs.stdenv) isLinux isx86_64;
in
lib.optionals (isLinux && isx86_64) [
self.nixosConfigurations.DANIELKNB1.config.home-manager.users.nixos
self.homeConfigurations."dani@maiziedemacchiato".config
]
)
++ (
let
inherit (pkgs.stdenv) isLinux isAarch64;
in
lib.optionals (isLinux && isAarch64) [
self.nixOnDroidConfigurations.sams9.config.home-manager.config
]
)
));
})

(mkApp system "nixos-shell" {
Expand Down Expand Up @@ -769,9 +727,9 @@ deploy-rs = {
// {
nilApp = null;
}
#// {
#// {
# deploy-rs = inputs.deploy-rs.apps.${system}.default;
#}
#}
);

checks = forEachSystem (system: {
Expand All @@ -786,18 +744,18 @@ deploy-rs = {
buildInputs = [ pkgs.git self.nixosConfigurations.DANIELKNB1.pkgs.neovim ];
} ''
mkdir -p "$out"
mkdir -p "$out"
# prevent E886 ('/home-shelter' error)
export HOME=$TMPDIR
# presumes prior devenv shell run in ~/debugpy-devshell/, https://github.com/mfussenegger/nvim-dap-python/blob/408186a/README.md#debugpy
export VIRTUAL_ENV=/home/dkahlenberg/debugpy-devshell/.devenv/state/venv
nvim --headless +":scriptnames | q" 2> "$out/nvim.log"
export HOME=$TMPDIR
# presumes prior devenv shell run in ~/debugpy-devshell/, https://github.com/mfussenegger/nvim-dap-python/blob/408186a/README.md#debugpy
export VIRTUAL_ENV=/home/dkahlenberg/debugpy-devshell/.devenv/state/venv
nvim --headless +":scriptnames | q" 2> "$out/nvim.log"
if [ -n "$(cat "$out/nvim.log")" ]; then
echo "output: "$(cat "$out/nvim.log")""
exit 1
fi
echo "output: "$(cat "$out/nvim.log")""
exit 1
fi
'';
*/
});
Expand Down Expand Up @@ -876,7 +834,7 @@ deploy-rs = {
cljShell = inputs.clojure-dev-template.devShells.${system}.default;
ocamlShell = inputs.ocaml-dev-template.devShells.${system}.default;
nixdShell = inputs.nixd.devShells.${system}.default;
jupyShell = inputs.ml_env.devShells.${system}.default;
jupyShell = inputs.ml_env.devShells.${system}.default;
}
*/
);
Expand Down
29 changes: 14 additions & 15 deletions flake/builders/mkDeploy.nix
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
{
inputs,
rootPath,
system,
pkgsFor,
name,
...
{ inputs
, rootPath
, system
, pkgsFor
, name
, ...
}:

let
Expand All @@ -15,21 +14,21 @@ let
deployerSystem = builtins.elemAt splittedName 1;

in
/**
see also ./../../lib/common-config.nix `homeManager.baseConfig.extraSpecialArgs` there and `homeManager.userConfig`
*/
/**
see also ./../../lib/common-config.nix `homeManager.baseConfig.extraSpecialArgs` there and `homeManager.userConfig`
*/



import "${rootPath}/hosts/${devicename}/deploy.nix" { inherit inputs; pkgs = pkgsFor.${system}; depPkgs = pkgsFor.${deployerSystem}; }

import "${rootPath}/hosts/${devicename}/deploy.nix" { inherit inputs; pkgs = pkgsFor.${system}; depPkgs = pkgsFor.${deployerSystem}; }


/*
{
hostname = "localhost";
profiles.system = {
profiles.system = {
user = "nix-on-droid";
sshUser = "nix-on-droid";
sshUser = "nix-on-droid";
path = inputs.deploy-rs.lib.x86_64-linux.activate.custom inputs.latest.legacyPackages.aarch64-linux.hello "./bin/hello";
};
}
Expand Down
2 changes: 1 addition & 1 deletion flake/nixpkgs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
allowUnfreePredicate =
pkg:
builtins.elem (inputs.nixpkgs.lib.getName pkg) [
"nvidia-x11"
"google-chrome"
];
},
Expand Down Expand Up @@ -106,7 +107,6 @@ import pkgsSet {
}
// genAttrs [
"nix-inspect"
"nixvim-config"
"bundix"
"talon"
"devenv"
Expand Down
3 changes: 3 additions & 0 deletions home/base/general.nix
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ in
# not inherit not same attr
lightWeight = cfg.lightWeight;
};
shell.shellAliases = {
nixbuild-shell = "nix run nixpkgs#rlwrap ssh eu.nixbuild.net shell";
};
};

programs = {
Expand Down
8 changes: 4 additions & 4 deletions home/programs/helix.nix
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ in
name = "nix";
formatter.command = "nixfmt";
language-servers = [
language-server.nixd = with pkgs.nixd; [
command = "${nixd}/bin/nixd";
args = ["--inlay-hints" "--semantic-tokens"];
config.nixd.options.home-manager.expr = '(builtins.getFlake "${rootDir}").homeConfigurations.nix-on-droid.options';
# language-server.nixd = with pkgs.nixd; [
# command = "${nixd}/bin/nixd";
# args = ["--inlay-hints" "--semantic-tokens"];
# config.nixd.options.home-manager.expr = '(builtins.getFlake "${rootDir}").homeConfigurations.nix-on-droid.options';
];
}
{
Expand Down
Loading

0 comments on commit 67882a5

Please sign in to comment.