mod/direnv: add nix shell
This commit is contained in:
parent
154c9de515
commit
0a74fec499
3 changed files with 12 additions and 0 deletions
|
@ -3,6 +3,7 @@ use crate::module::direnv::DirenvModuleArgs;
|
|||
#[derive(Debug, Clone, clap::ValueEnum)]
|
||||
pub enum DirenvCliNixValue {
|
||||
Flake,
|
||||
Shell,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, clap::Args)]
|
||||
|
@ -16,6 +17,7 @@ pub struct DirenvModuleCliArgs {
|
|||
impl From<DirenvModuleCliArgs> for DirenvModuleArgs {
|
||||
fn from(args: DirenvModuleCliArgs) -> Self {
|
||||
DirenvModuleArgs {
|
||||
nix_shell: matches!(args.nix, Some(DirenvCliNixValue::Shell)),
|
||||
nix_flake: matches!(args.nix, Some(DirenvCliNixValue::Flake)),
|
||||
nodejs: args.nodejs,
|
||||
}
|
||||
|
|
|
@ -9,6 +9,10 @@ pub struct DirenvModuleConfig {
|
|||
impl From<DirenvModuleConfig> for DirenvModuleArgs {
|
||||
fn from(cfg: DirenvModuleConfig) -> Self {
|
||||
DirenvModuleArgs {
|
||||
nix_shell: cfg
|
||||
.nix
|
||||
.map(|v| v.to_lowercase() == "shell")
|
||||
.unwrap_or_default(),
|
||||
nix_flake: cfg
|
||||
.nix
|
||||
.map(|v| v.to_lowercase() == "flake")
|
||||
|
|
|
@ -2,6 +2,10 @@ use std::collections::HashMap;
|
|||
|
||||
use super::Module;
|
||||
|
||||
const NIX_SHELL_PART: &str = "\
|
||||
# nix
|
||||
use nix";
|
||||
|
||||
const NIX_FLAKE_PART: &str = "\
|
||||
# nix
|
||||
use flake";
|
||||
|
@ -11,12 +15,14 @@ const NODEJS_PART: &str = "\
|
|||
layout node";
|
||||
|
||||
pub struct DirenvModuleArgs {
|
||||
pub nix_shell: bool,
|
||||
pub nix_flake: bool,
|
||||
pub nodejs: bool,
|
||||
}
|
||||
|
||||
fn make_gitignore_content(args: DirenvModuleArgs) -> String {
|
||||
[
|
||||
args.nix_shell.then_some(NIX_SHELL_PART),
|
||||
args.nix_flake.then_some(NIX_FLAKE_PART),
|
||||
args.nodejs.then_some(NODEJS_PART),
|
||||
]
|
||||
|
|
Loading…
Reference in a new issue