Merge pull request 'Upgrade to use Nix Flakes' (#4) from upgrade-to-flakes into main

Reviewed-on: https://git.softinio.com/softinio/nix-config/pulls/4
This commit is contained in:
Salar Rahmanian 2022-08-13 17:47:18 +00:00
commit 48421bb10e
5 changed files with 265 additions and 76 deletions

35
darwin-configuration.nix Normal file
View file

@ -0,0 +1,35 @@
{ pkgs, nix, nixpkgs, config, lib, ... }:
{
environment.systemPackages = with pkgs;
[
home-manager
];
fonts = {
fontDir.enable = true;
fonts = with pkgs; [
fira-code
];
};
programs.fish.enable = true;
system.stateVersion = 4;
users = {
users.salar = {
home = /Users/salar;
};
};
nix = {
nixPath = lib.mkForce [
"nixpkgs=${nixpkgs}"
];
package = pkgs.nixUnstable;
extraOptions = ''
experimental-features = nix-command flakes
'';
distributedBuilds = false;
};
services.nix-daemon.enable = true;
}

102
flake.lock Normal file
View file

@ -0,0 +1,102 @@
{
"nodes": {
"darwin": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1657835815,
"narHash": "sha256-CnZszAYpNKydh6N7+xg+eRtWNVoAAGqc6bg+Lpgq1xc=",
"owner": "lnl7",
"repo": "nix-darwin",
"rev": "54a24f042f93c79f5679f133faddedec61955cf2",
"type": "github"
},
"original": {
"owner": "lnl7",
"ref": "master",
"repo": "nix-darwin",
"type": "github"
}
},
"home-manager": {
"inputs": {
"nixpkgs": [
"nixpkgs"
],
"utils": "utils"
},
"locked": {
"lastModified": 1659878744,
"narHash": "sha256-81a9Mx5pDMBGN4WnVhcQVkW5mXNTZOt8DZOSI8bVKpU=",
"owner": "nix-community",
"repo": "home-manager",
"rev": "f5e9879e74e6202e2dbb3628fad2d20eac0d8be4",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "home-manager",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1659803779,
"narHash": "sha256-+5zkHlbcbFyN5f3buO1RAZ9pH1wXLxCesUJ0vFmLr9Y=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "f44884060cb94240efbe55620f38a8ec8d9af601",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nur": {
"locked": {
"lastModified": 1659937593,
"narHash": "sha256-tJBCAV7GwxxisvnlUK5YWwzeCm4q9OGgvEE9WFiypiI=",
"owner": "nix-community",
"repo": "nur",
"rev": "6daa0a7c4ae5c3951ac945b299d40e232674aaaf",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nur",
"type": "github"
}
},
"root": {
"inputs": {
"darwin": "darwin",
"home-manager": "home-manager",
"nixpkgs": "nixpkgs",
"nur": "nur"
}
},
"utils": {
"locked": {
"lastModified": 1653893745,
"narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

34
flake.nix Normal file
View file

@ -0,0 +1,34 @@
{
description = "Nix and home-manager configurations for Softinio's macbook";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
nur.url = github:nix-community/nur;
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
darwin = {
url = "github:lnl7/nix-darwin/master";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = {darwin, home-manager, nur, nixpkgs, ...}:
let
homeManagerConfFor = config: { ... }: {
nixpkgs.overlays = [ nur.overlay ];
imports = [ config ];
};
darwinSystem = darwin.lib.darwinSystem {
system = "x86_64-darwin";
modules = [
./darwin-configuration.nix
home-manager.darwinModules.home-manager {
home-manager.users.salar = homeManagerConfFor ./home.nix;
}
];
specialArgs = { inherit nixpkgs; };
};
in {
defaultPackage.x86_64-darwin = darwinSystem.system;
};
}

142
home.nix
View file

@ -8,19 +8,86 @@
nixpkgs.overlays = [ nixpkgs.overlays = [
(import ./overlays/sumneko-lua-language-server) (import ./overlays/sumneko-lua-language-server)
(import (builtins.fetchTarball { # (import (builtins.fetchTarball {
url = https://github.com/nix-community/neovim-nightly-overlay/archive/master.tar.gz; # url = https://github.com/nix-community/neovim-nightly-overlay/archive/master.tar.gz;
})) # }))
];
nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
"vscode"
]; ];
home = { home = {
username = "salar";
homeDirectory = "/Users/salar";
stateVersion = "21.11"; stateVersion = "21.11";
sessionVariables = { sessionVariables = {
EDITOR = "nvim"; EDITOR = "nvim";
VISUAL = "$EDITOR"; VISUAL = "$EDITOR";
}; };
packages = with pkgs; [
( python39.withPackages (ps: with ps; [ pip flake8 black ]) )
adoptopenjdk-bin
any-nix-shell
aspell
bloop
cabal-install
cachix
cmake
coursier
curlFull
exa
fd
ffmpeg
gitAndTools.diff-so-fancy
gnupg
go
haskellPackages.implicit-hie
hugo
lazydocker
luajit
luajitPackages.luarocks
luajitPackages.luasocket
lorri
maven
multimarkdown
mypy
ncdu
neofetch
neovim
niv
nix-index
nixfmt
nixFlakes
nodePackages.pyright
nodePackages.typescript-language-server
nodePackages.vscode-html-languageserver-bin
nodePackages.vscode-json-languageserver
nodePackages.yaml-language-server
openssl
pandoc
patchelf
poetry
rclone
readline
ripgrep
ripgrep-all
rnix-lsp
rustup
sbt
scala-cli
shellcheck
sqlite
stylua
stack
# sumneko-lua-language-server
tealdeer
tig
tokei
tree
tree-sitter
wget
xz
yq
];
}; };
programs.bat = { programs.bat = {
@ -29,7 +96,6 @@
programs.direnv = { programs.direnv = {
enable = true; enable = true;
enableFishIntegration = true;
nix-direnv.enable = true; nix-direnv.enable = true;
}; };
@ -218,7 +284,7 @@
v="nvim"; v="nvim";
tabninecfg="vc /Users/salar/Library/Preferences/TabNine/TabNine.toml"; tabninecfg="vc /Users/salar/Library/Preferences/TabNine/TabNine.toml";
sshfre1="ssh salar@fre1.softinio.net"; sshfre1="ssh salar@fre1.softinio.net";
sshfre2="ssh salar@fre2.softinio.net"; sshfre2="ssh -p 2022 salar@fre2.softinio.net";
}; };
}; };
@ -231,66 +297,4 @@
# Neovim Configuration # Neovim Configuration
xdg.configFile."nvim/lua/salargalaxyline.lua".source = programs/neovim/settings/salargalaxyline.lua; xdg.configFile."nvim/lua/salargalaxyline.lua".source = programs/neovim/settings/salargalaxyline.lua;
xdg.configFile."nvim/init.lua".source = programs/neovim/init.lua; xdg.configFile."nvim/init.lua".source = programs/neovim/init.lua;
home.packages = [
pkgs.adoptopenjdk-bin
pkgs.any-nix-shell
pkgs.aspell
pkgs.bloop
pkgs.cmake
pkgs.coursier
pkgs.curlFull
pkgs.direnv
pkgs.dust
pkgs.exa
pkgs.fd
pkgs.ffmpeg
pkgs.gitAndTools.diff-so-fancy
pkgs.global
pkgs.gnupg
pkgs.go
pkgs.hugo
pkgs.jansson
pkgs.luajit
pkgs.luajitPackages.luarocks
pkgs.luajitPackages.luasocket
pkgs.maven
pkgs.multimarkdown
pkgs.ncdu
pkgs.neofetch
pkgs.neovim
pkgs.niv
pkgs.nixFlakes
pkgs.nixfmt
pkgs.nodePackages.pyright
pkgs.nodePackages.typescript-language-server
pkgs.nodePackages.vscode-html-languageserver-bin
pkgs.nodePackages.vscode-json-languageserver
pkgs.nodePackages.yaml-language-server
pkgs.openssl
pkgs.pandoc
pkgs.prettyping
pkgs.procs
pkgs.python3Full
pkgs.python39Packages.debugpy
pkgs.readline
pkgs.ripgrep
pkgs.ripgrep-all
pkgs.rnix-lsp
pkgs.rustup
pkgs.sbt
pkgs.scala-cli
pkgs.shellcheck
pkgs.stylua
pkgs.sumneko-lua-language-server
pkgs.tealdeer
pkgs.tig
pkgs.tokei
pkgs.tree
pkgs.tree-sitter
pkgs.universal-ctags
pkgs.wget
pkgs.xz
pkgs.yq
];
} }

View file

@ -7,6 +7,7 @@ let
pager = "diff-so-fancy | less --tabs=4 -RFX"; pager = "diff-so-fancy | less --tabs=4 -RFX";
}; };
init.defaultBranch = "main"; init.defaultBranch = "main";
merge.conflictStyle = "diff3";
merge.tool = "intellij"; merge.tool = "intellij";
mergetool = { mergetool = {
cmd = "idea merge \"$LOCAL\" \"$REMOTE\" \"$BASE\" \"$MERGED\""; cmd = "idea merge \"$LOCAL\" \"$REMOTE\" \"$BASE\" \"$MERGED\"";
@ -23,20 +24,24 @@ let
insteadOf = "https://github.com/"; insteadOf = "https://github.com/";
}; };
}; };
fetch.prune = true;
pull = { pull = {
rebase = true; rebase = true;
}; };
}; };
in myAliases = {
{ ci = "commit";
programs.git = { co = "checkout";
enable = true; main = "checkout main";
userEmail = "code@softinio.com"; master = "checkout master";
userName = "Salar Rahmanian"; };
ignores = [ myIgnores = [
"*~" "*~"
".DS_Store" ".DS_Store"
"*.bloop" "*.bloop"
".direnv/"
".idea/"
".mypy_cache"
"*.metals" "*.metals"
"*.metals.sbt" "*.metals.sbt"
"*metals.sbt" "*metals.sbt"
@ -47,7 +52,16 @@ in
"*.idea" "*.idea"
"*.vscode" "*.vscode"
"*.python-version" "*.python-version"
"result"
]; ];
in
{
programs.git = {
enable = true;
userEmail = "code@softinio.com";
userName = "Salar Rahmanian";
aliases = myAliases;
ignores = myIgnores;
extraConfig = gitConfig; extraConfig = gitConfig;
}; };
} }